缩小以适合FOP中的图像 [英] Scale down to fit an image in FOP
问题描述
我使用FOP 1.0版来创建PDF。在其中一个页面中,我想显示一个图像(2552 x 4200像素),如果它不完全适合页面,则将其缩小。据我所见,邮件列表推荐的方法如下:
I am using FOP version 1.0 to create PDFs. In one of the pages I'd like to display an image (2552 x 4200 pixel) and scale it down if it doesn't fully fit on the page. As far as I could see on the mailing list the recommended way of doing this would be following:
<fo:external-graphic inline-progression-dimension.maximum="100%"
content-height="scale-down-to-fit"
content-width="scale-down-to-fit"
src="..."/>
不幸的是,仍然无法显示整个图像。图像的下半部分被切掉。任何人都可以给我一个关于我可能做错的提示吗?
Unfortunately, that still doesn't display the whole image. The lower part of the image is cut off. Can anyone give me a hint on what I am potentially doing wrong?
推荐答案
I found this page here explaining how scaling works with XSL-FO.
从本质上讲,这是我用来使其工作的片段:
Essentially, this is the snippet that I used to make it work:
<fo:external-graphic
src="url('...')"
width="100%"
content-height="100%"
content-width="scale-to-fit"
scaling="uniform"
xsl:use-attribute-sets="img"/>
我发现 width =100%
是你自己尝试中缺失的一块。希望这有助于未来的访客。
I found that width="100%"
was the missing piece in your own attempts. Hope this helps future visitors.
这篇关于缩小以适合FOP中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!