SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Table td problems when converting to PDF

    I created some simple HTML/CSS templates to use for creating PDF files for dynamically-driven reports. When I look at the templates as HTML files in my browser, the tables look fine, but after they're converted to PDFs, all the ths and tds have double lines like in the screenshot. I can insert a css reset stylesheet into the template and it clears it up - but that messes up the other styles. What are the specific resets I need to fix this?

    badTable.gif

  2. #2
    SitePoint Mentor bronze trophy
    ronpat's Avatar
    Join Date
    Jun 2012
    Location
    NJ, USA
    Posts
    2,456
    Mentioned
    61 Post(s)
    Tagged
    2 Thread(s)
    Can you post a link to a test page? Can you describe how you are creating the .pdf from an html file? We need more information to be useful to you.

  3. #3
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,881
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    PDF files are usually created using the print stylesheet rather than the screen stylesheet. If you want to create PDFs of web pages, it is a good idea to create a print stylesheet for this purpose. Without seeing your CSS it is difficult to be sure exactly where the problem is.

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,786
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Have you tried just applying the reset to the td and not to all tags?
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I ended up putting this:

    table {
    border-collapse: collapse;
    border-spacing: 0;
    }

    as the very last thing in the print stylesheet. I had it at the beginning of the stylesheet but evidently there was something else in there that was cancelling it out. I'm not sure what it would be, though. There are no other border-collapse or border-spacing styles at all. Seems very odd.

  6. #6
    SitePoint Mentor bronze trophy
    ronpat's Avatar
    Join Date
    Jun 2012
    Location
    NJ, USA
    Posts
    2,456
    Mentioned
    61 Post(s)
    Tagged
    2 Thread(s)
    Thanks for posting the resolution. Glad you were able to fix it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •