【问题标题】:XSL rendering a PDF in PDFXSL 在 PDF 中呈现 PDF
【发布时间】:2019-02-26 11:00:27
【问题描述】:

我遇到了将本地 .pdf 放入我渲染的 PDF 的问题。 我目前有一个图片模板,我可以轻松地将图像加载到我的 PDF 中。

<!-- Picture -->
    <xsl:template match="picture">
        <fo:block text-align="left">
            <fo:external-graphic src="url('file:///C:/Images/testImage.jpeg')" content-height="5cm" />
        </fo:block>
    </xsl:template>

我想知道是否可以以与 PDF 相同的方式完成此操作。 目前我没有成功尝试使用

xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"

所以我所做的看起来像这样:

<!-- Chart which is saved as PDF-->
    <xsl:template match="chart">
        <fo:block text-align="left">
            <fox:external-document content-type="pdf" src="url('file:///C:/Pdfs/ExampleChart.pdf')"/>
        </fo:block>
    </xsl:template>

我正在使用 FOP 2.3,我得到的错误是

org.apache.fop.fo.flow.Block 不能转换为 org.apache.fop.fo.pagination.Root

所以我希望我不能在那里使用 fox:external-document,但这正是我需要 PDF 的地方。

感谢您的帮助!!!

【问题讨论】:

    标签: apache pdf xslt apache-fop


    【解决方案1】:

    好吧,我想我只是幸运地找到了我自己正在寻找的解决方案! 我刚刚将来自:HERE 的 jar 文件添加到 FOP 文件夹的 lib 目录中。然后我就可以像这样嵌入 PDF:

    <!-- Chart -->
    <xsl:template match="chart">
        <fo:block text-align="left">
            <fo:external-graphic src="url('file:///C:/Pdfs/ExampleChart.pdf')"/>
        </fo:block>
    </xsl:template>
    

    希望这将帮助任何遇到同样问题的人:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-13
      • 2015-11-07
      • 1970-01-01
      • 2015-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多