You use DocBook so you can generate multiple output formats. Two of those formats are PDF and HTML. You take a few screenshots now and then. They look fine either in your PDF or your HTML, but not both. You RTFM, Bob Stayton’s online book covering the XSL stylesheets, but you do not want conditional markup and stylesheet customizations to deal with it all. You wake up at 5 a.m. wondering what to do.
And then you find this note towards the bottom of http://stackoverflow.com/questions/4261838/xsl-fo-image-size-issue-with-pdfs:
“@Ace, PNG files have DPI information embedded within them. You can manipulate that information for example with programs from the ImageMagick suite. (So, for example, if you have a 800 px wide PNG that you want to present as a 5 inch wide image, you could just change the DPI information accordingly by
mogrify -density 160 -units PixelsPerInch image.png.) – Jukka Matilainen Nov 24 ’10 at 20:55″
Thanks so much, Jukka. Yours is some of the best doc I’ve read this week. Even the 160 density is right on for me. Plus, I learned something that I should have known but did not know about PDF.
I made a copy of my images directory, moved the original to images.orig, and then ran a one-liner.
$ for file in *.png; do mogrify -density 160 -units PixelsPerInch $file; done
The PDF now looks fine, no more overflowing screenshots. The HTML remains unaffected.
