缩小以适合FOP中的图像

时间:2011-06-02 20:58:29

标签: image pdf size xsl-fo apache-fop

我使用FOP 1.0版来创建PDF。在其中一个页面中,我想显示一个图像(2552 x 4200像素),如果它不完全适合页面,则将其缩小。据我所知mailing list,建议的方法是:

<fo:external-graphic inline-progression-dimension.maximum="100%" 
                     content-height="scale-down-to-fit" 
                     content-width="scale-down-to-fit" 
                     src="..."/>

不幸的是,仍然没有显示整个图像。图像的下半部分被切掉。任何人都可以给我一些关于我可能做错的提示吗?

2 个答案:

答案 0 :(得分:14)

I found this page here explaining how scaling works with 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%"是你自己尝试中缺失的部分。希望这有助于未来的访客。

答案 1 :(得分:3)

  

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

如果您未指定视口,则FOP将不知道将图像缩放到的内容。

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

相关问题