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.
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%"
, andcontentdepth="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 ...
Try <imagedata width="100%" scalefit="1">
. It's on each image in the source XML I know, but it will scale with various output media sizes.
Check out this page on image sizing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With