Ste*_*gny 5 pdf-generation xsl-fo apache-fop
我正在使用 FOP 2.1 并尝试设置 ViewerPreferences,例如 DisplayDocTitle -> true。
我正在尝试(从这个问题
<fo:declarations>
<pdf:dictionary type="Catalog" xmlns:pdf="http://xmlgraphics.apache/org/fop/extensions/pdf">
<pdf:dictionary type="normal" key="ViewerPreferences">
<pdf:entry key="DisplayDocTitle" type="boolean">true</pdf:entry>
</pdf:dictionary>
</pdf:dictionary>
<x:xmpmeta xmlns:x="adobe:ns:meta/">
...
Run Code Online (Sandbox Code Playgroud)
但得到
Jul 13, 2016 11:18:31 AM org.apache.fop.events.LoggingEventListener processEvent
WARNING: Unknown formatting object "{http://xmlgraphics.apache/org/fop/extensions/pdf}dictionary" encountered (a child of fo:declarations}. (See position 242:105)
Jul 13, 2016 11:18:31 AM org.apache.fop.events.LoggingEventListener processEvent
WARNING: Unknown formatting object "{http://xmlgraphics.apache/org/fop/extensions/pdf}dictionary" encountered (a child of dictionary}. (See position 243:69)
Run Code Online (Sandbox Code Playgroud)
并且 pdf 中没有 ViewerPreferences。
当我把字典放在下面<x:xmpmeta xmlns:x="adobe:ns:meta/">
时,我也没有得到 ViewerPreferences,只有 pdfbox preflight 会抱怨
The file test.pdf is not valid, error(s) :
7.3 : Error on MetaData, Cannot find a definition for the namespace http://xmlgraphics.apache/org/fop/extensions/pdf
Run Code Online (Sandbox Code Playgroud)
我做错了什么,我尝试太早了吗?我必须在哪里修补 fop?
根据FOP 2.0 的发行说明,除其他外,还引入了
/Catalog
增强 PDF和/Page
词典的低级机制
但网站上并没有太多使用它的例子。
查看源代码分发中包含的测试用例,特别是名为 的测试用例pdf-dictionary-extension_*.xml
,我能够将与您的代码类似的东西放在一起,但不会生成运行时异常;诚然,我对这个 PDF 功能还不够熟悉,无法判断输出是否真正实现了您想要做的事情:
<fo:declarations>
<pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
<pdf:dictionary type="normal" key="ViewerPreferences">
<pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
</pdf:dictionary>
</pdf:catalog>
</fo:declarations>
Run Code Online (Sandbox Code Playgroud)
<pdf:dictionary type="Catalog">
有pdf:catalog
<pdf:entry key="..." type="...">
元素,但每种可能的条目类型都有一个特定元素:pdf:array
, pdf:boolean
, pdf:name
, pdf:number
, pdf:string
, ...(披露:我是一名 FOP 开发人员,尽管现在不太活跃)