Why doesn't external graphical scalability downward work when the height is in percent?
Suppose I have a "tall.png" image that is too large for the box it fits into. I would like the image to be automatically scaled down to fit into the parent block.
A simple example of what I mean:
<fo:block-container height="10cm" width="10cm" border="solid 0.5px black">
<fo:block>
<fo:external-graphic src="tall.png"
content-width="scale-down-to-fit" content-height="scale-down-to-fit"
width="100%" height="100%"/>
</fo:block>
</fo:block-container>
The above code doesn't work. The resulting PDF file shows the image pouring out of the container block. On the other hand, if I do this ...
<fo:block-container height="10cm" width="10cm" border="solid 0.5px black">
<fo:block>
<fo:external-graphic src="tall.png"
content-width="scale-down-to-fit" content-height="scale-down-to-fit"
width="10cm" height="10cm"/>
</fo:block>
</fo:block-container>
It seems to work. This surprises me as the height property has to refer to the height of the containing block when you use percentages ( http://www.w3schools.com/xslfo/prop_height.asp ). This makes me think that using 100% and using 10cm in my example should be exactly the same, but they don't give the same result.
For the real problem I am trying to solve, I cannot hardcode the width and height for the outer graphics. I need it to stay within the height / width of its parent block, whatever it is. Any idea how to do this?
source to share
No one has answered this question yet
Check out similar questions: