/** * @param os * @param info * @throws IOException */ public XmpWriter(OutputStream os, PdfDictionary info, int PdfXConformance) throws IOException { this(os); if (info != null) { DublinCoreSchema dc = new DublinCoreSchema(); PdfSchema p = new PdfSchema(); XmpBasicSchema basic = new XmpBasicSchema(); PdfName key; PdfObject obj; for (Iterator it = info.getKeys().iterator(); it.hasNext(); ) { key = (PdfName) it.next(); obj = info.get(key); if (obj == null) continue; if (PdfName.TITLE.equals(key)) { dc.addTitle(((PdfString) obj).toUnicodeString()); } 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()); } if (PdfName.KEYWORDS.equals(key)) { p.addKeywords(((PdfString) obj).toUnicodeString()); } if (PdfName.CREATOR.equals(key)) { basic.addCreatorTool(((PdfString) obj).toUnicodeString()); } if (PdfName.PRODUCER.equals(key)) { p.addProducer(((PdfString) obj).toUnicodeString()); } if (PdfName.CREATIONDATE.equals(key)) { basic.addCreateDate(((PdfDate) obj).getW3CDate()); } if (PdfName.MODDATE.equals(key)) { basic.addModDate(((PdfDate) obj).getW3CDate()); } } if (dc.size() > 0) addRdfDescription(dc); if (p.size() > 0) addRdfDescription(p); if (basic.size() > 0) addRdfDescription(basic); if (PdfXConformance == PdfWriter.PDFA1A || PdfXConformance == PdfWriter.PDFA1B) { PdfA1Schema a1 = new PdfA1Schema(); if (PdfXConformance == PdfWriter.PDFA1A) a1.addConformance("A"); else a1.addConformance("B"); addRdfDescription(a1); } } }
/** * @param os * @param info * @throws IOException */ public XmpWriter(OutputStream os, Map info) throws IOException { this(os); if (info != null) { DublinCoreSchema dc = new DublinCoreSchema(); PdfSchema p = new PdfSchema(); XmpBasicSchema basic = new XmpBasicSchema(); String key; String value; for (Iterator it = info.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); key = (String) entry.getKey(); value = (String) entry.getValue(); if (value == null) continue; if ("Title".equals(key)) { dc.addTitle(value); } if ("Author".equals(key)) { dc.addAuthor(value); } if ("Subject".equals(key)) { dc.addSubject(value); dc.addDescription(value); } if ("Keywords".equals(key)) { p.addKeywords(value); } if ("Creator".equals(key)) { basic.addCreatorTool(value); } if ("Producer".equals(key)) { p.addProducer(value); } if ("CreationDate".equals(key)) { basic.addCreateDate(PdfDate.getW3CDate(value)); } if ("ModDate".equals(key)) { basic.addModDate(PdfDate.getW3CDate(value)); } } if (dc.size() > 0) addRdfDescription(dc); if (p.size() > 0) addRdfDescription(p); if (basic.size() > 0) addRdfDescription(basic); } }