缩小以适合 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?
推荐答案
我在这里找到了这个页面解释如何使用 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屋!