Author: ssteiner
Date: Mon Sep  9 09:08:12 2019
New Revision: 1866666

URL: http://svn.apache.org/viewvc?rev=1866666&view=rev
Log:
FOP-2882: Allow PDFFormXObject to improve performance

Added:
    
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFRendererConfiguratorTestCase.java
   (with props)
Modified:
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/pdf/PDFDocument.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererConfig.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOption.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
    
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/pdf/PDFDocument.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/pdf/PDFDocument.java?rev=1866666&r1=1866665&r2=1866666&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/pdf/PDFDocument.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/pdf/PDFDocument.java
 Mon Sep  9 09:08:12 2019
@@ -174,6 +174,8 @@ public class PDFDocument {
 
     private boolean linearizationEnabled;
 
+    private boolean formXObjectEnabled;
+
     protected boolean outputStarted;
 
     /**
@@ -1229,4 +1231,11 @@ public class PDFDocument {
         linearizationEnabled = b;
     }
 
+    public boolean isFormXObjectEnabled() {
+        return formXObjectEnabled;
+    }
+
+    public void setFormXObjectEnabled(boolean b) {
+        formXObjectEnabled = b;
+    }
 }

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererConfig.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererConfig.java?rev=1866666&r1=1866665&r2=1866666&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererConfig.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererConfig.java
 Mon Sep  9 09:08:12 2019
@@ -57,6 +57,7 @@ import static org.apache.fop.render.pdf.
 import static org.apache.fop.render.pdf.PDFEncryptionOption.USER_PASSWORD;
 import static 
org.apache.fop.render.pdf.PDFRendererOption.DISABLE_SRGB_COLORSPACE;
 import static org.apache.fop.render.pdf.PDFRendererOption.FILTER_LIST;
+import static org.apache.fop.render.pdf.PDFRendererOption.FORM_XOBJECT;
 import static org.apache.fop.render.pdf.PDFRendererOption.LINEARIZATION;
 import static org.apache.fop.render.pdf.PDFRendererOption.MERGE_FONTS;
 import static org.apache.fop.render.pdf.PDFRendererOption.OUTPUT_PROFILE;
@@ -150,7 +151,7 @@ public final class PDFRendererConfig imp
                 parseAndPut(DISABLE_SRGB_COLORSPACE, cfg);
                 parseAndPut(MERGE_FONTS, cfg);
                 parseAndPut(LINEARIZATION, cfg);
-
+                parseAndPut(FORM_XOBJECT, cfg);
                 parseAndPut(VERSION, cfg);
             } catch (ConfigurationException e) {
                 LogUtil.handleException(LOG, e, strict);

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOption.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOption.java?rev=1866666&r1=1866665&r2=1866666&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOption.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOption.java
 Mon Sep  9 09:08:12 2019
@@ -93,6 +93,12 @@ public enum PDFRendererOption implements
             return Boolean.valueOf(value);
         }
     },
+    FORM_XOBJECT("form-xobject", false) {
+        @Override
+        Boolean deserialize(String value) {
+            return Boolean.valueOf(value);
+        }
+    },
     /** Rendering Options key for the ICC profile for the output intent. */
     OUTPUT_PROFILE("output-profile") {
         @Override

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java?rev=1866666&r1=1866665&r2=1866666&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java
 Mon Sep  9 09:08:12 2019
@@ -33,6 +33,7 @@ import org.apache.fop.pdf.Version;
 
 import static 
org.apache.fop.render.pdf.PDFRendererOption.DISABLE_SRGB_COLORSPACE;
 import static org.apache.fop.render.pdf.PDFRendererOption.FILTER_LIST;
+import static org.apache.fop.render.pdf.PDFRendererOption.FORM_XOBJECT;
 import static org.apache.fop.render.pdf.PDFRendererOption.LINEARIZATION;
 import static org.apache.fop.render.pdf.PDFRendererOption.MERGE_FONTS;
 import static org.apache.fop.render.pdf.PDFRendererOption.OUTPUT_PROFILE;
@@ -142,4 +143,8 @@ public final class PDFRendererOptionsCon
     public Boolean getLinearizationEnabled() {
         return (Boolean)properties.get(LINEARIZATION);
     }
+
+    public Boolean getFormXObjectEnabled() {
+        return (Boolean)properties.get(FORM_XOBJECT);
+    }
 }

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRenderingUtil.java?rev=1866666&r1=1866665&r2=1866666&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
 Mon Sep  9 09:08:12 2019
@@ -620,6 +620,7 @@ class PDFRenderingUtil {
         this.pdfDoc.enableAccessibility(userAgent.isAccessibilityEnabled());
         pdfDoc.setMergeFontsEnabled(rendererConfig.getMergeFontsEnabled());
         
pdfDoc.setLinearizationEnabled(rendererConfig.getLinearizationEnabled());
+        pdfDoc.setFormXObjectEnabled(rendererConfig.getFormXObjectEnabled());
 
         return this.pdfDoc;
     }

Modified: 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java?rev=1866666&r1=1866665&r2=1866666&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java
 Mon Sep  9 09:08:12 2019
@@ -31,6 +31,7 @@ import static org.apache.fop.render.pdf.
 import static org.apache.fop.render.pdf.PDFEncryptionOption.USER_PASSWORD;
 import static 
org.apache.fop.render.pdf.PDFRendererOption.DISABLE_SRGB_COLORSPACE;
 import static org.apache.fop.render.pdf.PDFRendererOption.FILTER_LIST;
+import static org.apache.fop.render.pdf.PDFRendererOption.FORM_XOBJECT;
 import static org.apache.fop.render.pdf.PDFRendererOption.OUTPUT_PROFILE;
 import static org.apache.fop.render.pdf.PDFRendererOption.PDF_A_MODE;
 import static org.apache.fop.render.pdf.PDFRendererOption.PDF_X_MODE;
@@ -93,6 +94,11 @@ public final class PDFRendererConfBuilde
         return this;
     }
 
+    public PDFRendererConfBuilder setFormXObjectEnabled(boolean b) {
+        createTextElement(FORM_XOBJECT, String.valueOf(b));
+        return this;
+    }
+
     public final class EncryptionParamsBuilder {
         private final Element el;
 

Added: 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFRendererConfiguratorTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFRendererConfiguratorTestCase.java?rev=1866666&view=auto
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFRendererConfiguratorTestCase.java
 (added)
+++ 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFRendererConfiguratorTestCase.java
 Mon Sep  9 09:08:12 2019
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.fop.render.pdf;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+
+import javax.xml.transform.stream.StreamResult;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.fop.apps.AbstractRendererConfiguratorTest;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.FopFactory;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.apps.PDFRendererConfBuilder;
+import org.apache.fop.pdf.PDFDocument;
+import org.apache.fop.render.intermediate.IFContext;
+import org.apache.fop.render.intermediate.IFException;
+
+public class PDFRendererConfiguratorTestCase extends
+        AbstractRendererConfiguratorTest<PDFRendererConfigurator, 
PDFRendererConfBuilder> {
+
+    public PDFRendererConfiguratorTestCase() throws IFException {
+        super(MimeConstants.MIME_PDF, PDFRendererConfBuilder.class, 
PDFDocumentHandler.class);
+        FOUserAgent userAgent = FopFactory.newInstance(new 
File(".").toURI()).newFOUserAgent();
+        docHandler = new MyPDFDocumentHandler(new IFContext(userAgent));
+        docHandler.setResult(new StreamResult(new ByteArrayOutputStream()));
+    }
+
+    static class MyPDFDocumentHandler extends PDFDocumentHandler {
+        MyPDFDocumentHandler(IFContext context) {
+            super(context);
+        }
+
+        PDFDocument getThePDFDocument() {
+            return getPDFDocument();
+        }
+    }
+
+    @Override
+    public void setUpDocumentHandler() {
+    }
+
+    @Override
+    protected PDFRendererConfigurator createConfigurator() {
+        return new PDFRendererConfigurator(userAgent, new 
PDFRendererConfig.PDFRendererConfigParser());
+    }
+
+    private MyPDFDocumentHandler getDocHandler() {
+        return (MyPDFDocumentHandler) docHandler;
+    }
+
+    @Test
+    public void testFormXObjectEnabled() throws Exception {
+        parseConfig(createBuilder().setFormXObjectEnabled(true));
+        docHandler.startDocument();
+        
Assert.assertTrue(getDocHandler().getThePDFDocument().isFormXObjectEnabled());
+    }
+}

Propchange: 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFRendererConfiguratorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-h...@xmlgraphics.apache.org

Reply via email to