SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2009
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What else can I try in CSS to get PDF printed page to smaller print size...

    I'm using an online service to convert HTML to PDF sized for viewing on a Kindle. My target line length is 50 characters per line. However, I reach that number only when I don't include images in the conversion (see #1 below).

    You can look at the HTML page I'm working on. Its a chapter from an public domain book (see the pastebin #2 below). The HTML is a basic html page with some complex tables. The images and text are simply in divs in the body.

    I've made the following changes to the original HTML,
    * Added css to the html header:
    pre {white-space: pre-wrap;}
    img {max-width: 380px;} //I've tweaked this last number down to as low as this 200px, see file #3 below;
    * Changed inline image values from their original px to %
    * Deleted the image height property (to maintain proportionality)

    As you can see in file #3, I can get full control over the image size with these changes; however, the smaller image only works to shrink the page width up to a point (approx 55-60 cpl). I can only achieve the line length in file #1 when I don't include images.

    What have I missed?

    --
    Desired line width (without images)
    [1]: https://docs.google.com/file/d/0B7q1...it?usp=sharing

    Modified HTML
    [2]: http://pastebin.com/uNuEabpc

    PDF with image max-width = 200px
    [3]: https://docs.google.com/file/d/0B7q1...it?usp=sharing
    Last edited by xtiansimon; Sep 18, 2013 at 14:10. Reason: old sig; wack formatting

  2. #2
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    39,803
    Mentioned
    158 Post(s)
    Tagged
    4 Thread(s)
    Hi,

    I'm afraid I don't know anything about pdf but you say it works when you don't include images so have you tried just including one image to see if it immediately breaks? If it doesn't break with one image then it will be a matter of eliminating/adding images to find out where the problem occurs.

    If it does break with one image then it may be something to do with the conversion software I guess.

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2009
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I also communicated with the conversion site programmers who suggested a similar solution with the HTML--take the large HTML file and make it into something smaller. In other words eliminate some of the CSS styles/HTML content to reduce the complexity. All very good suggestions.
    Last edited by xtiansimon; Sep 20, 2013 at 13:22. Reason: reword
    Dinopad R40 - F15/XP
    APACHE 2
    MYSQL 5
    PHP 5


Tags for this Thread

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
  •