Reputation: 65
I find many similar questions, but not this: I have xml documents with markup for images which don't specify image dimensions. The image widths and heights are always smaller than a page if they are not scaled up and start at the top of the page.
The images are not inline (external-graphic is within a block). They always have a title (text) before them. If the image is wide, it works to use scale-to-fit and width 100%. If the image is tall, it runs off the bottom of the page, if the height is set large enough, and has keep-with-previous="always".
Before calling the XSL formatter, I know the pixel dimensions of the images (all raster), and I know the accumulated top and bottom margins
Is there a way to make sure the image will always fit on the page, when it's tall?
Upvotes: 0
Views: 153
Reputation: 8068
Because the images are small and you're using Antenna House Formatter, there's axf:image-resolution
(https://www.antenna.co.jp/AHF/help/en/ahf-ext.html#axf.image-resolution) for setting the resolution of individual graphics. If you set related graphics to the same, fairly low DPI, you'll get a far more consistent appearance than by scaling every graphic to fill the available width.
If a fixed low DPI mostly works but makes some images too wide/high, you could also or instead use allowed-width-scale
and/or allowed-height-scale
(https://www.w3.org/TR/xsl11/#allowed-height-scale) to get a few controlled scales. (I've never combined axf:image-resolution
with either, myself, but that might be what you want.)
Or you could try axf:image-resolution
with content-width="scale-down-to-fit"
so that larger graphics fill the width of the text block.
Because you know the sizes of the images, you could also set min-height
(https://www.w3.org/TR/xsl11/#min-height) based on some scale factor applied to the images so that the images can't be too small, either.
Upvotes: 0
Reputation: 8068
Add max-height="100%"
to the fo:external-graphic
. (See https://www.w3.org/TR/xsl11/#max-height)
<fo:block font-weight="bold" space-before="1lh">Figure title</fo:block>
<fo:block keep-with-previous="always" text-align="center">
<fo:external-graphic width="100%" max-height="100%" content-width="scale-to-fit"
src="formatter-V7_V.jpg" />
</fo:block>
<fo:block space-before="1lh">Lorem ipsum dolor sit amet consectetur.</fo:block>
<fo:block font-weight="bold" space-before="1lh">Figure title</fo:block>
<fo:block keep-with-previous="always" text-align="center">
<fo:external-graphic width="100%" max-height="100%" content-width="scale-to-fit"
src="formatter-V7_H.jpg" />
</fo:block>
<fo:block font-weight="bold" space-before="1lh">Figure title</fo:block>
<fo:block keep-with-previous="always" text-align="center">
<fo:external-graphic width="100%" max-height="100%" content-width="scale-to-fit"
src="formatter-V7_V.jpg" />
</fo:block>
Upvotes: 0