Does FOP 2.1 support ViewerPreferences?

I am using FOP 2.1 and trying to set ViewerPreferences, for example. DisplayDocTitle -> true.

I'm trying (from this question

<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/"> ... 

but getting

 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) 

and no ViewerPreferences inside pdf.

When I put the dictionaries below <x:xmpmeta xmlns:x="adobe:ns:meta/"> then I also do not get ViewerPreferences, only the prefax pdfbox will 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 

What am I doing wrong, am I too early to try? Where do I need to install fop?

+4
source share
2 answers

In accordance with the release notes, FOP 2.0 introduced, inter alia,

  • Low level mechanism for enlarging PDF /Catalog and /Page dictionaries

but there are not many examples of its use on the website.

Looking at the testcases included in the source distribution, in particular those named pdf-dictionary-extension_*.xml , I was able to compile something like your code that does not throw an exception at runtime; admittedly, I'm not familiar enough with this PDF function to say if the result really reaches 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> 
  • no <pdf:dictionary type="Catalog"> , instead pdf:catalog
  • there are no <pdf:entry key="..." type="..."> elements, but for every possible record type there is a certain element: pdf:array , pdf:boolean , pdf:name , pdf:number , pdf:string , ...

(disclosure: I'm a FOP developer, although not very active at this time)

+2
source

As a complement to @lfurini's excellent detection, here's something else that can be done so easily, tested with fop 2.1, but might also work from 2.0 :, remove the comments from the relevant sections to try:

 <fo:declarations> <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf"> <!-- this opens in full-screen mode, eg as presentation --> <!-- pdf:name key="PageMode">FullScreen</pdf:name --> <!-- this opens then second page so it is fully visible --> <!-- (count seems to start at 0) --> <!-- pdf:array key="OpenAction"> <pdf:number>1</pdf:number> <pdf:name>Fit</pdf:name> </pdf:array --> <!-- this will replace the window title from filename to below dc:title --> <pdf:dictionary type="normal" key="ViewerPreferences"> <pdf:boolean key="DisplayDocTitle">true</pdf:boolean> </pdf:dictionary> </pdf:catalog> <x:xmpmeta xmlns:x="adobe:ns:meta/"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/"> <!-- Dublin Core properties go here --> <dc:title>Sample Document title</dc:title> </rdf:Description> </rdf:RDF> </x:xmpmeta> </fo:declarations> 

Details of the possible values ​​can be found in the pdf specification (from page 139 in this version v1.7, TABLE 3.25 Entries in the dictionary directory), take care not to use the values ​​that are usually set by fop in any case, limit themselves to viewing material / reading.

0
source

All Articles