Skip to main content
January 9, 2008
Answered

Read/write XMP Metadata

  • January 9, 2008
  • 3 replies
  • 2880 views
can anyone advise on how to read and write XMP metadata using the version of iText that ships with CF8?

we've successfully written XMP metadata into a PDF (see attached proof-of-concept code bolted together from a couple of sources), but this metadata doesn't display within Acrobat Pro 7's File Properties - Additional Metadata and also doesn't appear to be readable using iText's PDFReader class to read the same file (via PdfReader.getMetadata()).

we've compared the raw file output between a CF-generated iText-created PDF and a PDF containing readable metadata created with another app. the CF iText PDF is adding XMP header/footer XML to the RDF packet towards the tail of the PDF stream, and is not adding RDF metadata to the head of the PDF file.

we've also tried creating our own XMPSchema with our custom namespace, but get an instantiation error when trying to create the new XMPSchema.
This topic has been closed for replies.
Correct answer -__cfSearching__-
The XmpArray constructor expects one of the constant values. Not the literal string "UNORDERED".

Change your instantiation code from this
subject = CreateObject("java","com.lowagie.text.xml.xmp.XmpArray").init("UNORDERED");

To this
XmpArray = CreateObject("java","com.lowagie.text.xml.xmp.XmpArray");
subject = XmpArray.init(XmpArray.UNORDERED);

3 replies

Inspiring
January 10, 2008
You are welcome.
January 10, 2008
my bad, thank you. Acrobat is now reading the XMP data correctly.

EDITED Jan 2008 to add XMP getMetadata() example code... hope this helps someone.

-__cfSearching__-Correct answer
Inspiring
January 10, 2008
The XmpArray constructor expects one of the constant values. Not the literal string "UNORDERED".

Change your instantiation code from this
subject = CreateObject("java","com.lowagie.text.xml.xmp.XmpArray").init("UNORDERED");

To this
XmpArray = CreateObject("java","com.lowagie.text.xml.xmp.XmpArray");
subject = XmpArray.init(XmpArray.UNORDERED);