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?
Add
max-height="100%"to thefo:external-graphic. (See https://www.w3.org/TR/xsl11/#max-height)