From: Simon Steiner Date: Tue, 12 Oct 2021 13:33:49 +0000 (+0000) Subject: FOP-3006: XMP Metadata in created PDF/A-2 documents is not valid X-Git-Tag: fop-2_7~22 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ceca366bda2ccb180008952c43e10d80fe425b30;p=xmlgraphics-fop.git FOP-3006: XMP Metadata in created PDF/A-2 documents is not valid Thanks to J Frank git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1894162 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFMetadata.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFMetadata.java index 3af9af606..107dba9fa 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFMetadata.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFMetadata.java @@ -146,7 +146,7 @@ public class PDFMetadata extends PDFStream { DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta); //PDF/A identification PDFAMode pdfaMode = pdfDoc.getProfile().getPDFAMode(); - dc.setCompact(pdfaMode.getPart() != 3); + dc.setCompact((pdfaMode.getPart() != 3) && (pdfaMode.getPart() != 2)); if (info.getAuthor() != null) { dc.addCreator(info.getAuthor()); } diff --git a/fop-core/src/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java b/fop-core/src/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java index 6ff40b3c3..8f8afc8f4 100644 --- a/fop-core/src/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java @@ -20,12 +20,15 @@ package org.apache.fop.render.pdf; import java.util.Calendar; +import java.util.Locale; import java.util.TimeZone; import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import org.apache.xmlgraphics.xmp.Metadata; import org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter; @@ -35,6 +38,7 @@ import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema; import org.apache.xmlgraphics.xmp.schemas.pdf.AdobePDFAdapter; import org.apache.xmlgraphics.xmp.schemas.pdf.AdobePDFSchema; +import org.apache.fop.pdf.PDFAMode; import org.apache.fop.pdf.PDFDocument; import org.apache.fop.pdf.PDFInfo; import org.apache.fop.pdf.PDFMetadata; @@ -115,4 +119,28 @@ public class PDFAMetadataTestCase { assertEquals(cal1.getTime(), xmp.getCreateDate()); assertEquals(cal2.getTime(), xmp.getModifyDate()); } + + @Test + public void testXMPMetaDataForLanguageAndDateForPDF2A() throws Exception { + PDFDocument doc = new PDFDocument("SuperFOP"); + doc.getRoot().setLanguage(new Locale("en")); + doc.getProfile().setPDFAMode(PDFAMode.PDFA_2A); + Metadata meta = PDFMetadata.createXMPFromPDFDocument(doc); + assertTrue(meta.getProperty("http://purl.org/dc/elements/1.1/", "language").getValue().toString() + .contains("rdf:Bag")); + assertTrue(meta.getProperty("http://purl.org/dc/elements/1.1/", "date").getValue().toString() + .contains("rdf:Seq")); + } + + @Test + public void testXMPMetaDataForLanguageAndDateForPDF1A() throws Exception { + PDFDocument doc = new PDFDocument("SuperFOP"); + doc.getRoot().setLanguage(new Locale("en")); + doc.getProfile().setPDFAMode(PDFAMode.PDFA_1A); + Metadata meta = PDFMetadata.createXMPFromPDFDocument(doc); + assertFalse(meta.getProperty("http://purl.org/dc/elements/1.1/", "language").getValue().toString() + .contains("rdf:Bag")); + assertFalse(meta.getProperty("http://purl.org/dc/elements/1.1/", "date").getValue().toString() + .contains("rdf:Seq")); + } }