首页 > 解决方案 > Apache FOP 外部图形自动高度以适应页面

问题描述

我有一个场景,我使用fo:external graphic. 但是图像大小是动态的,我必须将其放入单页中。我通过保持如下纵横比来缩小水平和垂直图像。

<fo:block text-align="left" margin-top="10" 
        height="22cm" width="18cm">
    <fo:external-graphic height="100%" width="100%" 
            content-height="scale-to-fit" content-width="scale-to-fit" 
            scaling="uniform" >
        <xsl:attribute name="src">
            <xsl:text>url('data:image/png</xsl:text>
            <xsl:text>;base64,</xsl:text> 
            <xsl:value-of select="BASE_64_IMAGE"/>
            <xsl:text>')</xsl:text>
        </xsl:attribute>
    </fo:external-graphic>
</fo:block>

这适用于大型垂直图像。但是一旦按比例缩小,如果图像垂直尺寸较小,则文本内容不会填充到图像下方。相反,它将在下一页中填充。但如果图像很小,我希望文本显示在图像下方。

有人可以帮我解决这个问题吗?

标签: pdfscaleapache-fop

解决方案


推荐阅读