Hi,
i’m trying to generate a valid ZUGFeRD 2.x EN_16931 file.
If i add the xmp bevor the conversion to PDF/A-3 then the metadata is not there afterwards. If i add the xmp after the PDF/A-3 conversion the file is not a valid PDF/A-3 format. To validate if the file is valid i use https://www.portinvoice.com/
Here is the code i use to create my pdf file:
        String path = Paths.get(testPath, "RE-20201121_508.pdf").toString();
        File blanko = new File(path);
        assertTrue(blanko.exists());
        path = Paths.get(testPath, "factur-x.xml").toString();
        File zugferd = new File(path);
        assertTrue(zugferd.exists());
        String filename = "factur-x.xml";
        String jobId = "123"; // for logging
        Document doc = new Document(blanko.getAbsolutePath());
        File log = new File(Tools.getBasicTempDirectory(), "PDFmakeA3compliant_" + jobId + ".xml");
        DocumentInfo docInfo = new DocumentInfo(doc);
        docInfo.setAuthor("Lobster");
        docInfo.setProducer("Lobster Unit Test");
        docInfo.setCreator( "Lobster");
        docInfo.setCreationDate(new java.util.Date());
        docInfo.setModDate(new java.util.Date());
        docInfo.setSubject("PDFmakeA3compliant");
        byte[] xml = Files.readAllBytes(zugferd.toPath());
        String description = "Invoice metadata conforming to ZUGFeRD/Factur-X, Version: 1.0";
        FileSpecification fileSpecification = new FileSpecification(filename, description);
        fileSpecification.setContents(xml);
        fileSpecification.setMIMEType("text/xml");
        fileSpecification.setAFRelationship(AFRelationship.Alternative);// TODO change to DATA again
        fileSpecification.setName(filename);
        doc.getEmbeddedFiles().add(fileSpecification);
        Metadata meta = doc.getMetadata();
        String prefix = "fx";
        meta.registerNamespaceUri("pdfaid", "http://www.aiim.org/pdfa/ns/id/");
        meta.registerNamespaceUri(prefix, "urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#");
        meta.registerNamespaceUri("xmp", "http://ns.adobe.com/xap/1.0/");
        meta.registerNamespaceUri("pdf", "http://ns.adobe.com/pdf/1.3/");
        String now = ZonedDateTime.now(ZoneId.systemDefault()).toString();
        meta.setItem("xmp:CreateDate", new XmpValue(now));
        meta.setItem("xmp:CreatorTool", new XmpValue("Lobster ZUGFeRD-to-PDF/A Converter"));
        meta.setItem("xmp:ModifyDate", new XmpValue(now));
        meta.setItem("pdf:Producer", new XmpValue("Lobster data platform"));
        meta.setItem("pdfaid:part", new XmpValue("3")); // PDF/A-3
        meta.setItem("pdfaid:conformance", new XmpValue("A")); // Conformance level A
        meta.setItem(prefix + ":DocumentType", new XmpValue("INVOICE"));
        meta.setItem(prefix + ":DocumentFileName", new XmpValue(filename));
        meta.setItem(prefix + ":ConformanceLevel", new XmpValue("EN 16931"));
        meta.setItem(prefix + ":Version", new XmpValue("1.0"));
        meta.registerNamespaceUri("pdfaExtension", "http://www.aiim.org/pdfa/ns/extension/");
        meta.setItem("pdfaExtension:DocumentFileName", new XmpValue(filename));
        PdfFormatConversionOptions options = new PdfFormatConversionOptions(PdfFormat.PDF_A_3A, ConvertErrorAction.Delete);
        options.setLogFileName(log.getAbsolutePath());
        doc.convert(options);
        path = Paths.get(testPath, "Generated.pdf").toString();
        doc.save(path);
i also included all my pdf aswell as the invoce.xml
Files.zip (58,8 KB)