Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docbook maxwidth on images? (xml:fo)

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.

like image 967
pvgoddijn Avatar asked Dec 04 '09 12:12

pvgoddijn


2 Answers

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 ...
like image 122
David Citron Avatar answered Oct 19 '22 23:10

David Citron


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

like image 38
carillonator Avatar answered Oct 20 '22 00:10

carillonator