Movatterモバイル変換


[0]ホーム

URL:


 

Apache XML Graphics Project Logo

Apache™ FOP

This document is for an old version of FOP that is no longer supported.Latest version of this page
The Apache FOP Project

The Apache™ FOP Project

Apache™ FOP: Metadata

Overview

Document metadata is an important tool for categorizing and finding documents. Various formats support different kinds of metadata representation and to different levels. One of the more popular and flexible means of representing document or object metadata isXMP (eXtensible Metadata Platform, specified by Adobe). PDF 1.4 introduced the use of XMP. The XMP specification lists recommendation for embedding XMP metdata in other document and image formats. Given its flexibility it makes sense to make use this approach in the XSL-FO context. Unfortunately, unlike SVG which also refers to XMP, XSL-FO doesn't recommend a preferred way of specifying document and object metadata. Therefore, there's no portable way to represent metadata in XSL-FO documents. Each implementation does it differently.

Embedding XMP in an XSL-FO document

As noted above, there's no officially recommended way to embed metadata in XSL-FO. Apache™ FOP supports embedding XMP in XSL-FO. Currently, only support for document-level metadata is implemented. Object-level metadata will be implemented when there's interest.

Document-level metadata can be specified in thefo:declarations element. XMP specification recommends to usex:xmpmeta,rdf:RDF, andrdf:Description elements as shown in example below. Bothx:xmpmeta andrdf:RDF elements are recognized as the top-level element introducing an XMP fragment (as per the XMP specification).

Example

[..]</fo:layout-master-set><fo:declarations><x:xmpmetaxmlns:x="adobe:ns:meta/"><rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Descriptionrdf:about=""xmlns:dc="http://purl.org/dc/elements/1.1/"><!-- Dublin Core properties go here --><dc:title>Document title</dc:title><dc:creator>Document author</dc:creator><dc:description>Document subject</dc:description></rdf:Description><rdf:Descriptionrdf:about=""xmlns:xmp="http://ns.adobe.com/xap/1.0/"><!-- XMP properties go here --><xmp:CreatorTool>Tool used to make the PDF</xmp:CreatorTool></rdf:Description></rdf:RDF></x:xmpmeta></fo:declarations><fo:page-sequence...[..]

fo:declarationsmust be declared afterfo:layout-master-set and before the firstpage-sequence.

Implementation in Apache FOP

Currently, XMP support is only available for PDF output.

Originally, you could set some metadata information through FOP's FOUserAgent by using its set*() methods (like setTitle(String) or setAuthor(String). These values are directly used to set value in the PDF Info object. Since PDF 1.4, adding metadata as an XMP document to a PDF is possible. That means that there are now two mechanisms in PDF that hold metadata.

Apache FOP now synchronizes the Info and the Metadata object in PDF, i.e. when you set the title and the author through the FOUserAgent, the two values will end up in the (old) Info object and in the new Metadata object as XMP content. If instead of FOUserAgent, you embed XMP metadata in the XSL-FO document (as shown above), the XMP metadata will be used as-is in the PDF Metadata object and some values from the XMP metadata will be copied to the Info object to maintain backwards-compatibility for PDF readers that don't support XMP metadata.

The mapping between the Info and the Metadata object used by Apache FOP comes from thePDF/A-1 specification. For convenience, here's the mapping table:

Document information dictionary
Entry
PDF typeXMP PropertyXMP typeXMP Category
Titletext stringdc:titleTextExternal
Authortext stringdc:creatorseq TextExternal
Subjecttext stringdc:description["x-default"]TextExternal
Keywordstext stringpdf:KeywordsTextExternal
Creatortext stringxmp:CreatorToolTextExternal
Producertext stringpdf:ProducerTextInternal
CreationDatedatexmp:CreationDateDateInternal
ModDatedatexmp:ModifyDateDateInternal

"Internal" in the Category column means that the user should not set this value. It is set by the application.

The "Subject" used to be mapped todc:subject in the initial publication of PDF/A-1 (ISO 19005-1). In theTechnical Corrigendum 1 this was changed to map todc:description["x-default"].

Namespaces

Metadata is made of property sets where each property set uses a different namespace URI.

The following is a listing of namespaces that Apache FOP recognizes and acts upon, mostly to synchronize the XMP metadata with the PDF Info dictionary:

Set/SchemaNamespace PrefixNamespace URI
Dublin Coredchttp://purl.org/dc/elements/1.1/
XMP Basicxmphttp://ns.adobe.com/xap/1.0/
Adobe PDF Schemapdfhttp://ns.adobe.com/pdf/1.3/

Please refer to theXMP Specification for information on other metadata namespaces.

Property sets (Namespaces) not listed here are simply passed through to the final document (if supported). That is useful if you want to specify a custom metadata schema.

Links

PDF custom properties

It is possible to add custom key/value pairs in the Info dictionary of a PDF document. Those custom properties will appear in the ‘Custom’ tab of Adobe Reader’s ‘Document Properties’ window.

A pdf:info element can be added as a child of fo:declarations and contain the custom properties. For example:

<fo:declarations><pdf:infoxmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf"><pdf:namekey="MyProperty">MyValue</pdf:name><pdf:namekey="MyOtherProperty">MyOtherValue</pdf:name></pdf:info></fo:declarations>

PDF ViewerPreferences

You can set PDF viewer preferences for example using:

<fo:declarations><pdf:catalogxmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf"><pdf:dictionarykey="ViewerPreferences"><pdf:namekey="Duplex">DuplexFlipShortEdge</pdf:name></pdf:dictionary></pdf:catalog></fo:declarations>

There is a specific element for each possible entry type: pdf:array, pdf:boolean, pdf:name, pdf:number, pdf:string.For example:

<fo:declarations><pdf:layerid="Contents"><pdf:stringkey="Name">Contents</pdf:string></pdf:layer><pdf:layerid="Connections"><pdf:stringkey="Name">Connections</pdf:string></pdf:layer><pdf:catalog><pdf:dictionarykey="OCProperties"><pdf:arraykey="OCGs"><pdf:referencerefid="Contents"/><pdf:referencerefid="Connections"/></pdf:array><pdf:dictionarykey="D"><pdf:stringkey="Name">Default</pdf:string><pdf:namekey="BaseState">OFF</pdf:name></pdf:dictionary></pdf:dictionary></pdf:catalog></fo:declarations>

Example 1Example 2Example 3

PDF Page Piece

Allows indexing of PDF files for tools such as IBM Content Manager OnDemand

Usage (fo)

Add metadata for each page master based on how the software has been configured.

<fo:simple-page-mastermaster-name="simple"page-height="27.9cm"page-width="21.6cm"><fo:region-body/><pdf:pagepiece><pdf:dictionarykey="IBM-ODIndexes/Private"><pdf:stringkey="Cname">BUD</pdf:string></pdf:dictionary></pdf:pagepiece></fo:simple-page-master>

PDF page metadata

Allows attaching custom XMP metadata to a specific PDF page object

Usage (fo)

<fo:simple-page-mastermaster-name="simple"><fo:region-body/><pdf:pagepage-numbers="*"><x:xmpmetaxmlns:x="adobe:ns:meta/"><rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"xmlns:abc="http://www.abc.de/abc/"><rdf:Descriptionrdf:about=""abc:def="val"/><rdf:Descriptionrdf:about=""xmlns:pdfaExtension="http://www.aiim.org/pdfa/ns/extension/"xmlns:pdfaSchema="http://www.aiim.org/pdfa/ns/schema#"xmlns:pdfaProperty="http://www.aiim.org/pdfa/ns/property#"><pdfaExtension:schemas><rdf:Bag><rdf:lirdf:parseType="Resource"><pdfaSchema:property><rdf:Seq><rdf:lirdf:parseType="Resource"><pdfaProperty:name>split</pdfaProperty:name></rdf:li></rdf:Seq></pdfaSchema:property></rdf:li></rdf:Bag></pdfaExtension:schemas></rdf:Description></rdf:RDF></x:xmpmeta></pdf:page></fo:simple-page-master>
Apache Software Foundation

Copyright © 2025 The Apache Software Foundation, Licensed undertheApache License, Version 2.0.
Apache, Apache XML Graphics, Apache FOP, Apache Batik, the Apache logo, and theApache XML Graphics logos are trademarks ofThe ApacheSoftware Foundation. All other marks mentioned may be trademarks or registeredtrademarks of their respective owners.


[8]ページ先頭

©2009-2026 Movatter.jp