3

I have a large number of XML documents which are created in docbook and, through maven, are published in both an html for and a pdf form. The generations works fine, and the html looks fine. The issue i'm having is in the size of the images in the pdf version. The images are a collection of screenshots, some are full screen, some about 2/3rds width and height, and others are small search boxes. It's obvious that I need to do a massive refactor of the attributes of the imagedata. I was wondering what should I refactor it to? I'm looking for a way to create up to 4 'types' of images and for these to enforce their own sizing. An example of an image looks like this:

  <section><title>Screenshot</title>
     <mediaobject>
       <imageobject>
        <imagedata fileref="./views/screenshots/editNote.png" scalefit="0" width="100%"/>
       </imageobject>
     </mediaobject>
  </section>

And it only works for some of my screenshot sizes.

I've played around with scalefit, width, and contentwidth/contentheight and they seem solve different portions of the problem. Should I be looking into viewports as well?

NOTE: There is not fear of breaking html generation since I can turn on 'exclude properties' in the XSL.

Ace
  • 821
  • 3
  • 16
  • 37
  • Ace, it's not real clear what you're asking. You appear to be talking about the XSL-FO attributes scale-to-fit, content-width etc.? I tagged your question with xsl-fo because I think that's what you're talking about. Can you elaborate on what you mean by "*refactor* of the attributes"? – LarsH Nov 23 '10 at 23:19
  • I need to refactor the orginal docbook xml, and the xsl-fo once I know how I need to do images properly. – Ace Nov 23 '10 at 23:38

2 Answers2

4

This isn't strictly what you're asking, but have you normalized the DPI settings in your image files? Though ignored in HTML rendering, they're crucial in docbook->PDF rendering.

When I've dealt with this in the past, fixing the DPI left me with no need to further tweak the DocBook source.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
  • Is it as simple as adding that attribute to my imagedata? – Ace Nov 24 '10 at 07:13
  • 1
    @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
  • It seems that all of my screenshots have a 96*96 dpi. So some of the smaller images appear wide and tall being badly streched and the full screen shots seems to be over pixelated. Why cant these images appear like they do when I open them up in MS Paint or something? – Ace Nov 24 '10 at 22:50
1

You have @scalefit="0" try with @scalefit="1":

<section><title>Screenshot</title>
     <mediaobject>
       <imageobject>
        <imagedata fileref="./views/screenshots/editNote.png" 
                   scalefit="1" width="100%" contentdept="100%"/>
       </imageobject>
     </mediaobject>
  </section>  

Here is some guidance for using the scaling attributes.

  • To scale a graphic to a given width, set the contentwidth in the imagedata element to that size, for example contentwidth="8.5cm". If you specify a number without units, it is assumed to be pixels.

  • To scale a graphic to fit the available width in printed output, use width="100%" and scalefit="1" attributes. For indented text as in a list, the available width is from the current indent to the right margin.

  • To keep a graphic for printed output at its natural size unless it is too large to fit the available width, in which case shrink it to fit, use scalefit="1", width="100%", and contentdepth="100%" attributes.

...

  • Some XSL-FO processors do not support all of these attributes. You may need to experiment to see what works. For example, FOP version 0.20.5 treats width as if it were contentwidth and ignores any real contentwidth attribute.

http://www.sagehill.net/docbookxsl/ImageSizing.html

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
  • adding scalefit="1" width="100%" contentdept="100%" works for 90% of my screens. I still have a few which go beyond the page header or beyond the page footer. What should I do for those ones? They seem to have excessive height but I still want them to scale into the page – Ace Nov 25 '10 at 21:24