缩小以适合 FOP 中的图像

发布于 2024-11-13 06:00:56 字数 486 浏览 9 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

独守阴晴ぅ圆缺 2024-11-20 06:00:56

我在这里找到了这个页面,解释了缩放如何与 XSL-FO 一起使用

本质上,这是我用来使其工作的代码片段:

<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 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"/>

I found that width="100%" was the missing piece in your own attempts. Hope this helps future visitors.

岛徒 2024-11-20 06:00:56

定义“视口”的精确高度和宽度:
.

如果您不指定视口,那么 FOP 将不知道将图像缩放到什么程度。

它可以猜测,但不能准确知道。

Defining the exact height and width of the "viewport":
.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文