diff options
author | Simon Steiner <ssteiner@apache.org> | 2021-10-12 13:33:49 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2021-10-12 13:33:49 +0000 |
commit | ceca366bda2ccb180008952c43e10d80fe425b30 (patch) | |
tree | ea35985646ac7028fa219536664952855cbfb246 /fop-core | |
parent | de00379a8449375fddadd454ec343c92b63e66cf (diff) | |
download | xmlgraphics-fop-ceca366bda2ccb180008952c43e10d80fe425b30.tar.gz xmlgraphics-fop-ceca366bda2ccb180008952c43e10d80fe425b30.zip |
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
Diffstat (limited to 'fop-core')
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/pdf/PDFMetadata.java | 2 | ||||
-rw-r--r-- | fop-core/src/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java | 28 |
2 files changed, 29 insertions, 1 deletions
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")); + } } |