]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2625: Allow Attachments for PDF/A-3
authorSimon Steiner <ssteiner@apache.org>
Tue, 19 Jul 2016 09:25:55 +0000 (09:25 +0000)
committerSimon Steiner <ssteiner@apache.org>
Tue, 19 Jul 2016 09:25:55 +0000 (09:25 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1753357 13f79535-47bb-0310-9956-ffa450edef68

fop-core/src/main/java/org/apache/fop/pdf/PDFProfile.java
fop-core/src/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java
fop/test/xml/pdf-a/with-attachment.fo [new file with mode: 0644]

index 18140a59692b620a58fe1898291362da59f046ce..ef01a20b482c13def76ab94a1a8373da06db3f75 100644 (file)
@@ -332,7 +332,7 @@ public class PDFProfile {
     /** Checks if embedded files are allowed. */
     public void verifyEmbeddedFilesAllowed() {
         final String err = "{0} does not allow embedded files.";
-        if (isPDFAActive()) {
+        if (isPDFAActive() && getPDFAMode().getPart() < 3) {
             throw new PDFConformanceException(format(err, getPDFAMode()));
         }
         if (isPDFXActive()) {
index 752d666c53049203986da4e03219123b97b98fbc..acd4806157d9affa80cfa60419a1a4a6e8b7de3a 100644 (file)
@@ -131,6 +131,20 @@ public class PDFAConformanceTestCase extends BasePDFTest {
         eventChecker.end();
     }
 
+    @Test
+    public void testAttachment() throws Exception {
+        File foFile = new File(foBaseDir, "with-attachment.fo");
+        try {
+            convertFO(foFile, getUserAgent(), dumpPDF);
+            fail("Expected PDFConformanceException. PDF/A-1 does not allow attachments.");
+        } catch (PDFConformanceException e) {
+            //Good!
+        }
+        FOUserAgent ua = getUserAgent();
+        ua.getRendererOptions().put("pdf-a-mode", "PDF/A-3a");
+        convertFO(foFile, ua, dumpPDF);
+    }
+
     private EventChecker setupEventChecker(FOUserAgent ua, String expectedEvent) {
         Map<String, Object> params = new HashMap<String, Object>();
         params.put("pdfProfile", PDFAMode.PDFA_1B);
diff --git a/fop/test/xml/pdf-a/with-attachment.fo b/fop/test/xml/pdf-a/with-attachment.fo
new file mode 100644 (file)
index 0000000..f922c89
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fo:root xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Gladiator">
+  <fo:layout-master-set>
+    <fo:simple-page-master master-name="y" margin-right="10mm" margin-left="5mm" margin-bottom="5mm" margin-top="5mm" page-width="21cm" page-height="29.7cm">
+      <fo:region-body/>
+    </fo:simple-page-master>
+    <fo:page-sequence-master master-name="x">
+      <fo:repeatable-page-master-alternatives>
+        <fo:conditional-page-master-reference master-reference="y" page-position="any"/>
+      </fo:repeatable-page-master-alternatives>
+    </fo:page-sequence-master>
+  </fo:layout-master-set>
+  <fo:declarations>
+    <pdf:embedded-file filename="minimal-pdf-a.fo" src="xml/pdf-a/minimal-pdf-a.fo"/>
+  </fo:declarations>
+  <fo:page-sequence master-reference="x">
+    <fo:flow flow-name="xsl-region-body">
+      <fo:block>xx</fo:block>
+    </fo:flow>
+  </fo:page-sequence>
+</fo:root>