Author: ssteiner Date: Tue Oct 12 13:33:49 2021 New Revision: 1894162 URL: http://svn.apache.org/viewvc?rev=1894162&view=rev Log: FOP-3006: XMP Metadata in created PDF/A-2 documents is not valid Thanks to J Frank
Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/pdf/PDFMetadata.java xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/pdf/PDFMetadata.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/pdf/PDFMetadata.java?rev=1894162&r1=1894161&r2=1894162&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/pdf/PDFMetadata.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/pdf/PDFMetadata.java Tue Oct 12 13:33:49 2021 @@ -146,7 +146,7 @@ public class PDFMetadata extends PDFStre 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()); } Modified: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java?rev=1894162&r1=1894161&r2=1894162&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java Tue Oct 12 13:33:49 2021 @@ -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.schema 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")); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: fop-commits-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-commits-h...@xmlgraphics.apache.org