AW: AW: Embedding XMP in FO

2004-12-14 Thread Victor Röder
Hi Jeremias,

 We're hoping for any help we can get to bring the
 redesign effort to a point where we can release again. I'm pretty
 certain now, that will happen sometime next year, but not before summer.

I will see what I can do... thanks for the info anyway.

 Hm My guess is that you didn't take the right approach. See
 below for an example of an external FOP extension. It could be, however,
 that the old code (and maybe even the new) doesn't handle namespace
 prefixes in attributes well.

It works now... well it would have worked before: For testing I fancy-dumped
the XMP stream in a separate file. Fancy dump but incomplete dump :-)...
Stupid mistake.

Bye,
Victor


Re: AW: Embedding XMP in FO

2004-12-09 Thread Jeremias Maerki

On 09.12.2004 08:27:18 Victor Röder wrote:
 Hi Jeremias,
 
  you haven't told us what branch you are on. Are you on the maintenance
  branch or on FOP HEAD?
 
 I suppose I'm working with the 0.20.5 code base...
 
  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.
 
 I didn't had the chance to look at the HEAD branch yet. Is it in an
 stable/usable state?

Usable? Depends. :-) Stable? No. It's where we concentrate all our
efforts because the old maintenance branch is a dead end. The design of
the layout engine doesn't allow any further progress towards full
specification compliance. That's why we decided to freeze the
maintenance branch. We're hoping for any help we can get to bring the
redesign effort to a point where we can release again. I'm pretty
certain now, that will happen sometime next year, but not before summer.

  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.
 
 I tried to build up a separated DOM with the XMP data in it (similarly to
 the SVG stuff). But I think there are several restrictions so that I doubt
 that this could be done with the 0.20.5 sources.
 Examples: 1) There is no way to define an own PropertyHandler. There are two
 for FO and SVG, but they are in the fop.jar as class files. 2) The SAX
 parser does not submit the prefix bindings for namespaces (e.g.
 xmlns:xap=http://ns.adobe.com...;) as attributes. They are missing in the
 PropertyList. 3) Leaf text nodes are not submitted to
 FObj.addCharacters(...).

Hm My guess is that you didn't take the right approach. See
below for an example of an external FOP extension. It could be, however,
that the old code (and maybe even the new) doesn't handle namespace
prefixes in attributes well.

  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.
 
 Yes, you're right. Attaching it to the 'root' and to a 'block' or
 'foreign-instream-object' is sounder.
 
  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.
 
 Thanks, it helped me out. But I don't think that the 0.20.5 sources will get
 me any further... Btw: Did you notice that it does not compile if you remove
 the fop.jar with compiled sources from the classpath? There seem to be
 inconsistent packages between the fop.jar and the actual source directory
 tree.

Not sure, but could it be that you're forgetting that during the build
process code gets generated using XSLT in the build/codegen directory?
At least, I don't see any problems with the maintenance branch build.

  I hope this helps nonetheless. We're looking forward to your patches for
  FOP HEAD. ;)
 
 Well, we'll see :-). One request: Please do not see SVG as the *only*
 foreign XML vocabulary that one could embed in FO :-).

We don't. For example, I'm the author of Barcode4J which has a FOP
extension that enables you to use a special namespace to specify a
barcode in an fo:instream-foreign-object. It didn't even have to modify
the source code to implement this. See:

http://barcode4j.krysalis.org/fop-ext.html

Maybe the source code of that FOP extension might help you because they
do pretty much what you're trying to do: building a DOM from the
elements in the extension namespace.

http://cvs.sourceforge.net/viewcvs.py/barcode4j/barcode4j/src/fop-0.20.5/java/org/krysalis/barcode4j/fop0205/

I'm sorry that I don't have more time right now to dive in further but
maybe this helps.

Jeremias Maerki



AW: Embedding XMP in FO

2004-12-09 Thread Victor Röder
Hi,

 3) Leaf text nodes are not submitted to
 FObj.addCharacters(...).

hupps, that's not exactly true :-). addCharaters(...) *is* called and the
text node is appended to the appropriate element, but when dumping the
complete DOM this text node is missing.

Here is the XMP:

x:xmpmeta x:xmptk=XMP toolkit 2.9-9, framework 1.6
xmlns:x=adobe:ns:meta/
rdf:RDF xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#;
rdf:Description rdf:about=dieses-dokument
xmlns:xap=http://ns.adobe.com/xap/1.0/;
xap:CreatorTool
Vendor Application XYZ!-- This text node 
it is all about --
/xap:CreatorTool
/rdf:Description
/rdf:RDF
/x:xmpmeta

Here is the code:
~
protected void addCharacters ( char data[], int start, int length ) //
overrides ExtensionObj.addCharaters(...)
{
String str = new String( data, start, length );
Text text = this.document.createTextNode( str );

this.element.appendChild(text); // this works for all elements but for
xap:CreatorTool
}

After dumping the DOM:
~~
x:xmpmeta x:xmptk=XMP toolkit 2.9-9, framework 1.6
xmlns:x=adobe:ns:meta/
rdf:RDF xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#;
rdf:Description rdf:about=dieses-dokument
xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#;
xap:CreatorTool 
xmlns:xap=http://ns.adobe.com/xap/1.0//  !-- 
missing text node  --
/rdf:Description
/rdf:RDF
/x:xmpmeta


Any ideas?

Thanks,
Victor



AW: Embedding XMP in FO

2004-12-08 Thread Victor Röder
Hi Jeremias,

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

I suppose I'm working with the 0.20.5 code base...

 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.

I didn't had the chance to look at the HEAD branch yet. Is it in an
stable/usable state?

 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.

I tried to build up a separated DOM with the XMP data in it (similarly to
the SVG stuff). But I think there are several restrictions so that I doubt
that this could be done with the 0.20.5 sources.
Examples: 1) There is no way to define an own PropertyHandler. There are two
for FO and SVG, but they are in the fop.jar as class files. 2) The SAX
parser does not submit the prefix bindings for namespaces (e.g.
xmlns:xap=http://ns.adobe.com...;) as attributes. They are missing in the
PropertyList. 3) Leaf text nodes are not submitted to
FObj.addCharacters(...).

 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.

Yes, you're right. Attaching it to the 'root' and to a 'block' or
'foreign-instream-object' is sounder.

 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.

Thanks, it helped me out. But I don't think that the 0.20.5 sources will get
me any further... Btw: Did you notice that it does not compile if you remove
the fop.jar with compiled sources from the classpath? There seem to be
inconsistent packages between the fop.jar and the actual source directory
tree.

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

Well, we'll see :-). One request: Please do not see SVG as the *only*
foreign XML vocabulary that one could embed in FO :-).

Thank you,
Victor



Embedding XMP in FO

2004-12-02 Thread Victor Röder
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:DocumentIDuuid: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.6rdf: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:DocumentIDuuid: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



Re: Embedding XMP in FO

2004-12-02 Thread Jeremias Maerki
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:DocumentIDuuid: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.6rdf: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:DocumentIDuuid: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