]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-3006: XMP Metadata in created PDF/A-2 documents is not valid
authorSimon Steiner <ssteiner@apache.org>
Tue, 12 Oct 2021 13:33:49 +0000 (13:33 +0000)
committerSimon Steiner <ssteiner@apache.org>
Tue, 12 Oct 2021 13:33:49 +0000 (13:33 +0000)
Thanks to J Frank

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1894162 13f79535-47bb-0310-9956-ffa450edef68

fop-core/src/main/java/org/apache/fop/pdf/PDFMetadata.java
fop-core/src/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java

index 3af9af6067b9d271f6213428f9ccc272d3167340..107dba9fa56eb7c10a2b163e0a491effa9c38b4f 100644 (file)
@@ -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());
         }
index 6ff40b3c3b50b5b23576782adda4ff766c7f245d..8f8afc8f4761983b24709e284e06c4caef68a5b6 100644 (file)
 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"));
+    }
 }