簡體   English   中英

Apache FOP fox:使用PDF文件時外部文檔不起作用

[英]Apache FOP fox:external-document not working when using PDF file

我正在嘗試使用 Apache FOP fox:external-document附加 pdf 文檔,但在使用 pdf 類型時拋出以下異常:

SEVERE: Image not available. URI: /pathToPdf/file.pdf. Reason: org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for /pathToPdf/file.pdf (See position 202:89)
org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for /pathToPdf/file.pdf
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
    <xsl:template match="/">
        <fo:root>
            <fo:layout-master-set>
                ...
            </fo:layout-master-set>            

            <fox:external-document content-type="pdf" src="/pathToPdf/file.pdf"/>
        </fo:root>
    </xsl:template>
</xsl:stylesheet>

我正在使用 Apache FOP 2.3 和 Java 8

擴展屬性fox:external-document最初是為了在 pdf 輸出中插入圖像作為頁面。

為了將它與 pdf 文件一起使用,您需要PDF 圖像插件

只需下載並將(或鏈接)jar 放在 lib 文件夾中,一切都應該按預期工作。

從文件系統或資源添加 pdf 時對我來說工作正常:

Filesystem:
<fox:external-document src="url('file:D:///resource/test.pdf')"/>
Resource:
<fox:external-document src="url('file:resource/test.pdf')"/> 

Remember to add:
  xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf"
and 
  xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM