]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2353: PDF-A preflight warnings
authorSimon Steiner <ssteiner@apache.org>
Thu, 21 Aug 2014 14:42:22 +0000 (14:42 +0000)
committerSimon Steiner <ssteiner@apache.org>
Thu, 21 Aug 2014 14:42:22 +0000 (14:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1619415 13f79535-47bb-0310-9956-ffa450edef68

lib/xmlgraphics-commons-svn-trunk.jar
src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java

index 9eae34388498a6857f72d427b887fbe87e4e9ca4..7953685e51609d7ee91dfc13b74110889b102142 100644 (file)
Binary files a/lib/xmlgraphics-commons-svn-trunk.jar and b/lib/xmlgraphics-commons-svn-trunk.jar differ
index ef4824c6ae5b43705173171db5b7a42147f9770a..111cca6b284e2e8710ca51f9d53c9f25a8de4ad2 100644 (file)
@@ -26,6 +26,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.ArrayList;
 import java.util.EnumMap;
 import java.util.List;
 import java.util.Map;
@@ -36,6 +37,7 @@ import org.apache.commons.logging.LogFactory;
 
 import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil;
 import org.apache.xmlgraphics.xmp.Metadata;
+import org.apache.xmlgraphics.xmp.schemas.DublinCoreSchema;
 import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter;
 import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema;
 
@@ -246,7 +248,11 @@ class PDFRenderingUtil {
         Metadata docXMP = metadata.getMetadata();
         Metadata fopXMP = PDFMetadata.createXMPFromPDFDocument(pdfDoc);
         //Merge FOP's own metadata into the one from the XSL-FO document
-        fopXMP.mergeInto(docXMP);
+        List<Class> exclude = new ArrayList<Class>();
+        if (pdfDoc.getProfile().getPDFAMode().isPart1()) {
+            exclude.add(DublinCoreSchema.class);
+        }
+        fopXMP.mergeInto(docXMP, exclude);
         XMPBasicAdapter xmpBasic = XMPBasicSchema.getAdapter(docXMP);
         //Metadata was changed so update metadata date
         xmpBasic.setMetadataDate(new java.util.Date());
index 985974b804dd3ad664e22d929e0bb41648f3db2e..bd4be2a61f2de3ef565c4ba88004be0728fd17b0 100644 (file)
@@ -358,7 +358,10 @@ class PDFStructureTreeBuilder implements StructureTreeEventHandler {
     }
 
     public StructureTreeElement startNode(String name, Attributes attributes, StructureTreeElement parent) {
-        assert parent == null || parent instanceof PDFStructElem;
+        if (!isPDFA1Safe(name)) {
+            return null;
+               }
+               assert parent == null || parent instanceof PDFStructElem;
         PDFStructElem parentElem = parent == null ? ancestors.getFirst() : (PDFStructElem) parent;
         PDFStructElem structElem = createStructureElement(name, parentElem, attributes,
                 pdfFactory, eventBroadcaster);
@@ -367,7 +370,16 @@ class PDFStructureTreeBuilder implements StructureTreeEventHandler {
     }
 
     public void endNode(String name) {
-        ancestors.removeFirst();
+        if (isPDFA1Safe(name)) {
+            ancestors.removeFirst();
+        }
+    }
+
+    private boolean isPDFA1Safe(String name) {
+        return !(pdfFactory.getDocument().getProfile().getPDFAMode().isPart1()
+                && (name.equals("table-body")
+                || name.equals("table-header")
+                || name.equals("table-footer")));
     }
 
     public StructureTreeElement startImageNode(String name, Attributes attributes, StructureTreeElement parent) {