Hi Victor,

you haven't told us what branch you are on. Are you on the maintenance
branch or on FOP HEAD?

These hints are targeted at FOP HEAD code but some can be applied to the
maintenance branch, too, although the whole mechanism is quite different
there.

One thing you will have to do is creating an ElementMapping class (plus
node subclasses, or you extend the existing ExtensionElementMapping) so
the FOTreeBuilder can create nodes for each XML element of the various
namespaces in the metadata part. A good example in your case is the
bookmarks support code you can find in the org.apache.fop.fo.extensions
package. There you have an example of an ElementMapping class
(ExtensionElementMapping) and node classes (Bookmarks/Outline). That's
the first step.

The other issue is getting the metadata through to the PDFRenderer.
Since this is not an InstreamForeignObject or an ExternalGraphic, you
cannot use that infrastructure. But since the Bookmarks support is quite
similar to what you want to do, just follow these classes through the
code.

I'm not sure if attaching the metadata to a page-sequence is the right
approach. The page-sequence itself isn't represented in the resulting
PDF. You might also have multiple page-sequences in a document. So
you should probably attach it to fo:root where it applies to the whole
document. Attaching metadata to individual pages or objects is probably
trickier.

So for the fo:root attachment it is probably best to enhance the Root
class to catch the XMP data, just as it was done for Bookmarks. The FO
tree is one thing, you will also have to enhance the ...area.AreaTreeHandler
for the metadata. There's a class ...area.BookmarksData you might want
to look at. PDFRenderer.processOffDocumentItem() is finally responsible
to generate the outlines in the PDF. This can probably be used for the
metadata, too.

This should give you a few pointers into the code. I'm not sure if I got
everything right, because I'm not so familiar with this part, yet.
Hopefully, my colleagues will correct me if I wrote anything wrong.

I hope this helps nonetheless. We're looking forward to your patches for
FOP HEAD. ;)


On 02.12.2004 09:43:44 Victor Röder wrote:
> Hi Fop developers,
> 
> I'm using FOP to produce PDFs and I'm trying to embed XMP (a set of XML
> metadata-describing vocabularies "from" Adobe) in FO. These XMP packets
> should be serialized (nearly) one-to-one in a PDF tag for metadata.
> Here is an simple example:
> 
> <fo:page-sequence master-reference="default-page">
>  <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP toolkit 2.9-9, framework
> 1.6">
>   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns";>
>    <rdf:Description rdf:about="autodoc:tiff:c:/sample_path/sample.tiff"
> xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/";>
>     <xmpMM:DocumentID>uuid:foo:id-0815</xmpMM:DocumentID>
>    </rdf:Description>
>   </rdf:RDF>
>  </x:xmpmeta>
>  <fo:flow flow-name="xsl-region-body">
> 
>  [...]
> 
> </fo:page-sequence>
> 
> This XMP metadata says that the generated PDF "page sequence" is made of the
> sample.tiff.
> 
> Serialized to PDF it should look something like:
> (the best would be only for the first page of the TIFF page sequence)
> 
> 7 0 obj
> << /Type /Metadata /Subtype /XML /Length 541 >>stream
> <?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?><x:xmpmeta
> xmlns:x="adobe:ns:meta/" x:xmptk="XMP toolkit 2.9-9, framework 1.6"><rdf:RDF
> xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns";><rdf:Description
> rdf:about="autodoc:tiff:c:/sample_path/sample.tiff"
> xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/";><xmpMM:DocumentID>uuid:foo:id-
> 0815</xmpMM:DocumentID></rdf:Description></rdf:RDF></x:xmpmeta><?xpacket
> end="w"?>
> endstream
> endobj
> 
> Now my challenge: How can I do this as simple as possible. I tried to extend
> the FOP sources but permanently get lost, while searching how the FObjs of
> the FOTree get ready for the List of PDF objects to be rendered.
> 
> The problem is not the knowledge about XSL-FO nor PDF. I just don't have a
> view through the FOP sources. With which things do I have to start to embed
> the so-called foreign XML? I tried XMLObj but only got an "[ERROR] null".
> 
> Thanks in advance for your responce!
> 
> Bye,
>       Victor



Jeremias Maerki

Reply via email to