缩小以适合 FOP 中的图像
我正在使用 FOP 1.0 版来创建 PDF。在其中一个页面中,我想显示一张图像(2552 x 4200 像素),如果它不完全适合页面,则将其缩小。据我在邮件列表上看到推荐的方法如下:
<fo:external-graphic inline-progression-dimension.maximum="100%"
content-height="scale-down-to-fit"
content-width="scale-down-to-fit"
src="..."/>
不幸的是,这仍然不能显示整个图像。图像的下部被切除。谁能告诉我我可能做错了什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在这里找到了这个页面,解释了缩放如何与 XSL-FO 一起使用。
本质上,这是我用来使其工作的代码片段:
我发现
width="100%"
是您自己的尝试中缺少的部分。希望这对未来的访客有所帮助。I found this page here explaining how scaling works with XSL-FO.
Essentially, this is the snippet that I used to make it work:
I found that
width="100%"
was the missing piece in your own attempts. Hope this helps future visitors.如果您不指定视口,那么 FOP 将不知道将图像缩放到什么程度。
它可以猜测,但不能准确知道。
If you don't specify the viewport then FOP won't know what to scale your image to.
It can guess, but not know precisely.