docbook maxwidth on images? (xml:fo)

docbook, xsl-fo, xslt

Solution

A previous answer got very close with the correct link but missed the critical phrase on that page:

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.

That suggestion works well for a PDF generated by `fop`. If you're also generating HTML documentation, you'll have to add the following CSS:

img {
    max-width: 100%;
    width: auto;
    height: auto;
}

You can include CSS via:

$ xsltproc --stringparam html.stylesheet doc.css ...

Problem

is there a way to specify the maximum width of images in a docbook xsl-transform? we have a problem with screen shots being to big to fit on a page, and thus would like to set a max width on images in the output. specifying the width of the image in the Docbook XML files seems bad form (the Docbook file should be about content not presentation), a lot of manual work, and likely inconsistent sizes so is there a handy way to do this? image.default.width is not usefull because that alters images smaller then the 'page' width as well.

Original source