I have some code that I wrote to learn how to use iText.  The code
copies one file to another file.  I copy pages and metadata.  For some
reason adding metadata corrupts the file.  The original file was created
with Adobe Illustrator.  Without writing the metadata, AI can open the
copied file.  If I add the metadata, AI says: "Adcrobat PDF File Format
is having difficulties.  Expected a number object".  Yet, Acrobat Reader
has no problem opening the file. 

The code that writes the metadata is:

Byte meta[] = ...

com.lowagie.text.pdf.PdfStream stream = 
      new com.lowagie.text.pdf.PdfStream(meta);
com.lowagie.text.pdf.PdfName len = 
      new com.lowagie.text.pdf.PdfName(String.valueOf(meta.length));
stream.put(com.lowagie.text.pdf.PdfName.TYPE,
com.lowagie.text.pdf.PdfName.METADATA);
stream.put(com.lowagie.text.pdf.PdfName.SUBTYPE,
com.lowagie.text.pdf.PdfName.XML);
stream.put(com.lowagie.text.pdf.PdfName.LENGTH, len);
com.lowagie.text.pdf.PdfIndirectReference ref =
   pdfWriter.addToBody(stream).getIndirectReference();
pdfWriter.getExtraCatalog().put(com.lowagie.text.pdf.PdfName.METADATA,
ref);

------------
Eli Segev


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to