Acrobat 7 is quite out of date, no longer supported by Adobe, and does NOT follow the correct rules for XMP & DocInfo synchronization. DO NOT use it as a guide!
Leonard -----Original Message----- From: Federico Scala [mailto:[email protected]] Sent: Monday, December 28, 2009 10:06 AM To: 'Post all your questions about iText here' Subject: [iText-questions] "Subject" listed as a "keyword", or "what's wrong with createXmpMetadata()?" Hallo, list! I've noticed that in PDF with XMP I produced, the "Subject" text also shows as a single keyword when viewing the document properties with Reader. The problem, I recall, has been already discussed in this list (http://old.nabble.com/setMoreInfo%28%29--and-Acrobat-7---8-td21756031.html) , so I start reviewing my code -but I've found nothing wrong. A quick test with the example "HelloWorldXmpMetadata2.java" (and Itext 2.1.7/5.0.0) makes me think there's someting wrong in PdfWriter.createXmpMetadata(). I'm not an XMP expert, but after some searching and using as a reference the XMP data taken from a PDF created with Acrobat 7, I've modified XmpWriter constructors (from v2.1.7) as follows: ---------------------------------------------------------------------------- -------------------------------- --- XmpWriter.orig Tue Jun 09 06:16:40 2009 +++ XmpWriter.java Mon Dec 28 14:51:00 2009 @@ -213,17 +213,35 @@ if (obj == null) continue; if (PdfName.TITLE.equals(key)) { - dc.addTitle(((PdfString)obj).toUnicodeString()); + //dc.addTitle(((PdfString)obj).toUnicodeString()); + + LangAlt langAlt = new LangAlt(((PdfString)obj).toUnicodeString()); + dc.setProperty(DublinCoreSchema.TITLE, langAlt); } if (PdfName.AUTHOR.equals(key)) { dc.addAuthor(((PdfString)obj).toUnicodeString()); } if (PdfName.SUBJECT.equals(key)) { - dc.addSubject(((PdfString)obj).toUnicodeString()); - dc.addDescription(((PdfString)obj).toUnicodeString()); + // dc.addDescription(((PdfString)obj).toUnicodeString()); + LangAlt langAlt = new LangAlt(((PdfString)obj).toUnicodeString()); + dc.setProperty(DublinCoreSchema.DESCRIPTION, langAlt); } if (PdfName.KEYWORDS.equals(key)) { - p.addKeywords(((PdfString)obj).toUnicodeString()); + String keywords = ((PdfString)obj).toUnicodeString(); + + p.addKeywords(keywords); + + if ( keywords == null || keywords.equals("") ) { + dc.addSubject(keywords); + } else { + String [] keywordList = keywords.split(","); + int i; + + for ( i = 0; i < keywordList.length; i++ ) { + keywordList[i] = keywordList[i].trim(); + } + dc.addSubject(keywordList); + } } if (PdfName.CREATOR.equals(key)) { basic.addCreatorTool(((PdfString)obj).toUnicodeString()); @@ -278,11 +296,22 @@ dc.addAuthor(value); } if ("Subject".equals(key)) { - dc.addSubject(value); dc.addDescription(value); } if ("Keywords".equals(key)) { p.addKeywords(value); + + if ( value == null || value.equals("") ) { + dc.addSubject(value); + } else { + String [] keywordList = value.split(","); + int i; + + for ( i = 0; i < keywordList.length; i++ ) { + keywordList[i] = keywordList[i].trim(); + } + dc.addSubject(keywordList); + } } if ("Creator".equals(key)) { basic.addCreatorTool(value); ---------------------------------------------------------------------------- -------------------------------- (The "Subject" in DublinCore should be used as the keyword container, and each keyword should be stored into a separated item. The real "Subject" should go into DC "Description") With these "corrections" Acrobat stops rebuilding the keyword list. Using "LangAlt" for title and description also seems to produce a more conforming XMP. One more note: as described in the thread cited above, PdfSchema.java has been corrected to use "pdf:keywords" instead of "pdf:Keywords", but http://www.pdfa.org/doku.php?id=artikel:en:pdfa_metadata and TN0003 at http://www.pdfa.org/doku.php?id=pdfa:en:techdoc seems to assume that the original version is the good one. Am I missing something? Saluti & Auguri, -- Federico ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ iText-questions mailing list [email protected] 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/ ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ iText-questions mailing list [email protected] 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/
