Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top