FOP 2.1 是否支持 ViewerPreferences? [英] Does FOP 2.1 support ViewerPreferences?

查看:21
本文介绍了FOP 2.1 是否支持 ViewerPreferences?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 FOP 2.1 并尝试设置 ViewerPreferences,例如DisplayDocTitle -> 真.

I'm using FOP 2.1 and am trying to set ViewerPreferences, e.g. 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/">
    ...

但是得到

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)

pdf 中没有 ViewerPreferences.

and no ViewerPreferences inside the pdf.

当我将字典放在 <x:xmpmeta xmlns:x="adobe:ns:meta/"> 下方时,我也没有获得 ViewerPreferences,只有 pdfbox 预检会抱怨

When I put the dictionarys below the <x:xmpmeta xmlns:x="adobe:ns:meta/"> then I get no ViewerPreferences either, only pdfbox preflight will then complain about

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

我做错了什么,我尝试它是否为时过早?我必须在哪里修补 fop?

What am I doing wrong, am I too early to try it? Where do I have to patch fop?

推荐答案

根据 发行说明 FOP 2.0 引入了一个

According to the release notes FOP 2.0 introduced, among other things, a

  • 增强 PDF /Catalog/Page 词典的低级机制
  • Low level mechanism to augment PDF /Catalog and /Page dictionaries

但在网站上使用的例子并不多.

but there are not many examples of its usage in the website.

查看测试用例 包含在源代码分发中,特别是名为 pdf-dictionary-extension_*.xml 的那些,我能够将类似于您的代码的内容放在一起,不会生成运行时异常;诚然,我对这个 PDF 功能不够熟悉,无法说明输出是否真正实现了您想要做的:

Looking at the testcases included in the source distribution, in particular the ones named pdf-dictionary-extension_*.xml, I was able to put together something similar to your code which does not generate run-time exceptions; admittedly, I'm not familiar enough with this PDF feature to say whether the output actually achieves what you are trying to do:

<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>

  • 没有,取而代之的是pdf:catalog
  • 没有一个 <pdf:entry key="..." type="..."> 元素,但是每个可能的条目类型都有一个特定的元素:pdf:arraypdf:booleanpdf:namepdf:numberpdf:string, ...
    • there is no <pdf:dictionary type="Catalog">, there is pdf:catalog instead
    • there is not a single <pdf:entry key="..." type="..."> element, but there is a specific element for each possible entry type: pdf:array, pdf:boolean, pdf:name, pdf:number, pdf:string, ...
    • (披露:我是 FOP 开发人员,虽然现在不是很活跃)

      这篇关于FOP 2.1 是否支持 ViewerPreferences?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆