I made the changes to XmpReader and XmpWriter and have been trying on my own
to mess with it the last couple of days, but I am not doing something right.

Earlier with iText 2.1.5, I tried the overlay with a PDF/A-1b document
(attached here as Good_PDFA_1b.pdf) created using Adobe Pro 9 and the output
was still a PDF/A-1b.  But now after the changes to the two java programs,
executing the app against this PDF/A-1b displays the following message:
[Fatal Error] :94:2: The markup in the document following the root element
must be well-formed.
[Fatal Error] :94:2: The markup in the document following the root element
must be well-formed.

I then tried to run the app against the PDF/A-1b created by our vendor
(which has the PI tags missing) and I get this error message:
[Fatal Error] :5:17: The prefix "xmp" for element "xmp:ModifyDate" is not
bound.
[Fatal Error] :5:17: The prefix "xmp" for element "xmp:ModifyDate" is not
bound.

If this makes any sense to you guys, I would really appreciate your input. 
I have attached the two java source files
(trunk/src/core/com/lowagie/text/xml/xmp/XmpReader.java, 
http://www.nabble.com/file/p23966132/Good_PDFA_1b.pdf Good_PDFA_1b.pdf
trunk/src/core/com/lowagie/text/xml/xmp/XmpWriter.java) as well

Attached files:
http://www.nabble.com/file/t799222/Good_PDFA_1b.pdf
http://www.nabble.com/file/t799222/XmpWriter.java
http://www.nabble.com/file/t799222/XmpReader.java


1T3XT info wrote:
> 
> ek1975 wrote:
>> I didn't request that you fix anything for me.
> 
> It sounded that way. And in the meanwhile, here's the patch:
> 
> Log Message:
> -----------
> Updating the XMP stream assumed that there were three child nodes: an 
> xpacket start PI, an xmpmeta tag, and an xpacket end PI. However: 
> somebody posted an example that didn't have the xpacket PIs. This 
> changes makes sure the PIs are added.
> 
> Modified Paths:
> --------------
>      trunk/src/core/com/lowagie/text/xml/xmp/XmpReader.java
>      trunk/src/core/com/lowagie/text/xml/xmp/XmpWriter.java
> 
> Modified: trunk/src/core/com/lowagie/text/xml/xmp/XmpReader.java
> ===================================================================
> --- trunk/src/core/com/lowagie/text/xml/xmp/XmpReader.java    2009-06-03 
> 15:17:22 UTC (rev 3948)
> +++ trunk/src/core/com/lowagie/text/xml/xmp/XmpReader.java    2009-06-03 
> 15:19:04 UTC (rev 3949)
> @@ -168,15 +168,15 @@
>               XmlDomWriter xw = new XmlDomWriter();
>           ByteArrayOutputStream fout = new ByteArrayOutputStream();
>           xw.setOutput(fout, null);
> -        Node first = domDocument.getFirstChild();
> -        xw.write(first);
> -        fout.write('\n');
> -        xw.write(first.getNextSibling());
> +        NodeList xmpmeta = domDocument.getElementsByTagName("x:xmpmeta");
> +        fout.write(XmpWriter.XPACKET_PI_BEGIN.getBytes("UTF-8"));
>           fout.flush();
> +        xw.write(xmpmeta.item(0));
> +        fout.flush();
>               for (int i = 0; i < 20; i++) {
>                       fout.write(XmpWriter.EXTRASPACE.getBytes());
>               }
> -        xw.write(domDocument.getLastChild());
> +        fout.write(XmpWriter.XPACKET_PI_END_W.getBytes());
>           fout.close();
>           return fout.toByteArray();
>       }
> 
> Modified: trunk/src/core/com/lowagie/text/xml/xmp/XmpWriter.java
> ===================================================================
> --- trunk/src/core/com/lowagie/text/xml/xmp/XmpWriter.java    2009-06-03 
> 15:17:22 UTC (rev 3948)
> +++ trunk/src/core/com/lowagie/text/xml/xmp/XmpWriter.java    2009-06-03 
> 15:19:04 UTC (rev 3949)
> @@ -89,7 +89,25 @@
>       
>       /** The about string that goes into the rdf:Description tags. */
>       protected String about;
> +
> +     /**
> +      * Processing Instruction required at the start of an XMP stream
> +      * @since iText 2.1.6
> +      */
> +     public static final String XPACKET_PI_BEGIN = "<?xpacket 
> begin=\"\uFEFF\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?>\n";
>       
> +     /**
> +      * Processing Instruction required at the end of an XMP stream for XMP 
> streams that can be updated
> +      * @since iText 2.1.6
> +      */
> +     public static final String XPACKET_PI_END_W = "<?xpacket end=\"w\"?>";
> +     
> +     /**
> +      * Processing Instruction required at the end of an XMP stream for XMP 
> streams that are read only
> +      * @since iText 2.1.6
> +      */
> +     public static final String XPACKET_PI_END_R = "<?xpacket end=\"r\"?>";
> +     
>       /** The end attribute. */
>       protected char end = 'w';
>       
> @@ -103,7 +121,7 @@
>       public XmpWriter(OutputStream os, String utfEncoding, int extraSpace) 
> throws IOException {
>               this.extraSpace = extraSpace;
>               writer = new OutputStreamWriter(os, utfEncoding);
> -             writer.write("<?xpacket begin=\"\uFEFF\" 
> id=\"W5M0MpCehiHzreSzNTczkc9d\"?>\n");
> +             writer.write(XPACKET_PI_BEGIN);
>               writer.write("<x:xmpmeta xmlns:x=\"adobe:ns:meta/\">\n");
>               writer.write("<rdf:RDF 
> xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\";>\n");
>               about = "";
> @@ -171,7 +189,7 @@
>               for (int i = 0; i < extraSpace; i++) {
>                       writer.write(EXTRASPACE);
>               }
> -             writer.write("<?xpacket end=\"" + end + "\"?>");
> +             writer.write(end == 'r' ? XPACKET_PI_END_R : XPACKET_PI_END_W);
>               writer.flush();
>               writer.close();
>       }
> -- 
> This answer is provided by 1T3XT BVBA
> http://www.1t3xt.com/ - http://www.1t3xt.info
> 
> ------------------------------------------------------------------------------
> OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
> looking to deploy the next generation of Solaris that includes the latest 
> innovations from Sun and the OpenSource community. Download a copy and 
> enjoy capabilities such as Networking, Storage and Virtualization. 
> Go to: http://p.sf.net/sfu/opensolaris-get
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> Check the site with examples before you ask questions:
> http://www.1t3xt.info/examples/
> You can also search the keywords list:
> http://1t3xt.info/tutorials/keywords/
> 
> 
http://www.nabble.com/file/p23966132/XmpWriter.java XmpWriter.java 
http://www.nabble.com/file/p23966132/XmpReader.java XmpReader.java 
-- 
View this message in context: 
http://www.nabble.com/Overlay-text-content-on-PDF-A-1b-tp23762718p23966132.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to