PdfAXmpWriter extends XmpWriter { private void addRdfDescription(PdfAConformanceLevel conformanceLevel) throws XMPException { switch (conformanceLevel) { case PDF_A_1A: xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.PART, "1"); xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "A"); break; case PDF_A_1B: xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.PART, "1"); xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B"); break; case PDF_A_2A: xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.PART, "2"); xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "A"); break; case PDF_A_2B: xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.PART, "2"); xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B"); break; case PDF_A_2U: xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.PART, "2"); xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "U"); break; case PDF_A_3A: xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.PART, "3"); xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "A"); break; case PDF_A_3B: xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.PART, "3"); xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B"); break; case PDF_A_3U: xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.PART, "3"); xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "U"); break; case ZUGFeRD: case ZUGFeRDBasic: case ZUGFeRDComfort: case ZUGFeRDExtended: xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.PART, "3"); xmpMeta.setProperty(XMPConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B"); XMPMeta taggedExtensionMetaComfort = XMPMetaFactory.parseFromString(getZugferdExtension(conformanceLevel)); XMPUtils.appendProperties(taggedExtensionMetaComfort, xmpMeta, true, false); break; default: break; } if (writer.isTagged()) { XMPMeta taggedExtensionMeta = XMPMetaFactory.parseFromString(pdfUaExtension); XMPUtils.appendProperties(taggedExtensionMeta, xmpMeta, true, false); } } PdfAXmpWriter(OutputStream os, PdfAConformanceLevel conformanceLevel, PdfWriter writer);  PdfAXmpWriter(OutputStream os, PdfDictionary info, PdfAConformanceLevel conformanceLevel, PdfWriter writer);  PdfAXmpWriter(OutputStream os, Map<String, String> info, PdfAConformanceLevel conformanceLevel, PdfWriter writer);  static final String zugferdSchemaNS; static final String zugferdConformanceLevel; static final String zugferdDocumentFileName; static final String zugferdDocumentType; static final String zugferdVersion; }
@Test public void deprecatedLogicTest() throws IOException, DocumentException { String fileName = "xmp_metadata_deprecated.pdf"; Document document = new Document(); PdfWriter writer = PdfAWriter.getInstance(document, new FileOutputStream(OUT_FOLDER + fileName), PdfAConformanceLevel.PDF_A_2B); ByteArrayOutputStream os = new ByteArrayOutputStream(); XmpWriter xmp = new PdfAXmpWriter(os, PdfAConformanceLevel.PDF_A_2B, writer); XmpSchema dc = new com.itextpdf.text.xml.xmp.DublinCoreSchema(); XmpArray subject = new XmpArray(XmpArray.UNORDERED); subject.add("Hello World"); subject.add("XMP & Metadata"); subject.add("Metadata"); dc.setProperty(DublinCoreSchema.SUBJECT, subject); xmp.addRdfDescription(dc.getXmlns(), dc.toString()); PdfSchema pdf = new PdfSchema(); pdf.setProperty(PdfSchema.KEYWORDS, "Hello World, XMP & Metadata, Metadata"); pdf.setProperty(PdfSchema.VERSION, "1.4"); xmp.addRdfDescription(pdf); xmp.close(); writer.setXmpMetadata(os.toByteArray()); document.open(); document.addLanguage("en_US"); Font font = FontFactory.getFont("./src/test/resources/com/itextpdf/text/pdf/FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, 12); document.add(new Paragraph("Hello World", font)); ICC_Profile icc = ICC_Profile.getInstance(new FileInputStream("./src/test/resources/com/itextpdf/text/pdf/sRGB Color Space Profile.icm")); writer.setOutputIntents("Custom", "", "http: document.close(); CompareTool ct = new CompareTool(); Assert.assertNull(ct.compareXmp(OUT_FOLDER + fileName, CMP_FOLDER + "xmp_metadata_deprecated.pdf", true)); }