From: Simon Steiner Date: Thu, 21 Aug 2014 14:42:22 +0000 (+0000) Subject: FOP-2353: PDF-A preflight warnings X-Git-Tag: fop-2_0~75 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=967a5b18472f2f13db29dcff59b06aaedcc52b76;p=xmlgraphics-fop.git FOP-2353: PDF-A preflight warnings git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1619415 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/xmlgraphics-commons-svn-trunk.jar b/lib/xmlgraphics-commons-svn-trunk.jar index 9eae34388..7953685e5 100644 Binary files a/lib/xmlgraphics-commons-svn-trunk.jar and b/lib/xmlgraphics-commons-svn-trunk.jar differ diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java b/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java index ef4824c6a..111cca6b2 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java @@ -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 exclude = new ArrayList(); + 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()); diff --git a/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java b/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java index 985974b80..bd4be2a61 100644 --- a/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java +++ b/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java @@ -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) {