You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2008/02/07 15:02:48 UTC

svn commit: r619417 - in /xmlgraphics/fop/trunk: ./ src/documentation/content/xdocs/trunk/ src/java/org/apache/fop/render/pdf/ test/java/org/apache/fop/ test/java/org/apache/fop/render/pdf/

Author: jeremias
Date: Thu Feb  7 06:02:44 2008
New Revision: 619417

URL: http://svn.apache.org/viewvc?rev=619417&view=rev
Log:
Added an option to disable the default sRGB profile in PDF output for those who don't care about color fidelity, but care about PDF file size. Note that this option is not possible if PDF/A, PDF/X or an output profile is used. Makes simple PDFs about 4KB smaller. Ha!

Added:
    xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java   (with props)
Modified:
    xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml
    xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/output.xml
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
    xmlgraphics/fop/trunk/status.xml
    xmlgraphics/fop/trunk/test/java/org/apache/fop/StandardTestSuite.java

Modified: xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml?rev=619417&r1=619416&r2=619417&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml (original)
+++ xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml Thu Feb  7 06:02:44 2008
@@ -277,7 +277,23 @@
       <output-profile>C:\FOP\Color\EuropeISOCoatedFOGRA27.icc</output-profile>
       
       <fonts....
-    </renderer>]]></source>
+      </renderer>]]></source>
+      <p>
+        Some people don't have high requirements on color fidelity but instead want the smallest
+        PDF file sizes possible. In this case it's possible to disable the default sRGB color space
+        which XSL-FO requires. This will cause RGB colors to be generated as device-specific RGB.
+        Please note that this option is unavailable (and will cause an error) if you enable
+        PDF/A or PDF/X functionality or if you specify an output profile. This setting will make the
+        PDF about 4KB smaller. To disable the sRGB color space add the following setting:
+      </p>
+      <source><![CDATA[
+    <renderer mime="application/pdf">
+      <filterList...
+      
+      <disable-srgb-colorspace>true</disable-srgb-colorspace>
+      
+      <fonts....
+      </renderer>]]></source>
     </section>
     <section id="ps-renderer">
       <title>Special Settings for the PostScript Renderer</title>

Modified: xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/output.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/output.xml?rev=619417&r1=619416&r2=619417&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/output.xml (original)
+++ xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/output.xml Thu Feb  7 06:02:44 2008
@@ -105,7 +105,7 @@
       <section id="pdf-postprocess">
         <title>Post-processing</title>
         <p>
-          FOP does not currently support several desirable PDF features: XMP metadata and watermarks. 
+          FOP does not currently support several desirable PDF features: watermarks and signatures. 
           One workaround is to use Adobe Acrobat (the full version, not the Reader) to process 
           the file manually or with scripting that it supports.
         </p>

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java?rev=619417&r1=619416&r2=619417&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java Thu Feb  7 06:02:44 2008
@@ -147,6 +147,11 @@
     public static final String PDF_X_MODE = "pdf-x-mode";
     /** Rendering Options key for the ICC profile for the output intent. */
     public static final String KEY_OUTPUT_PROFILE = "output-profile";
+    /**
+     * Rendering Options key for disabling the sRGB color space (only possible if no PDF/A or
+     * PDF/X profile is active).
+     */
+    public static final String KEY_DISABLE_SRGB_COLORSPACE = "disable-srgb-colorspace";
 
     /** Controls whether comments are written to the PDF stream. */
     protected static final boolean WRITE_COMMENTS = true;
@@ -233,10 +238,10 @@
 
     /** the ICC stream used as output profile by this document for PDF/A and PDF/X functionality. */
     protected PDFICCStream outputProfile;
-    /** the ICC stream for the sRGB color space. */
-    //protected PDFICCStream sRGBProfile;
     /** the default sRGB color space. */
     protected PDFICCBasedColorSpace sRGBColorSpace;
+    /** controls whether the sRGB color space should be installed */
+    protected boolean disableSRGBColorSpace = false;
     
     /** Optional URI to an output profile to be used. */
     protected String outputProfileURI; 
@@ -344,6 +349,10 @@
         if (s != null) {
             this.outputProfileURI = s;
         }
+        setting = agent.getRendererOptions().get(KEY_DISABLE_SRGB_COLORSPACE);
+        if (setting != null) {
+            this.disableSRGBColorSpace = booleanValueOf(setting);
+        }
     }
 
     /**
@@ -387,11 +396,21 @@
     }
 
     private void addsRGBColorSpace() throws IOException {
-        if (this.sRGBColorSpace != null) {
-            return;
+        if (disableSRGBColorSpace) {
+            if (this.pdfAMode != PDFAMode.DISABLED
+                    || this.pdfXMode != PDFXMode.DISABLED
+                    || this.outputProfileURI != null) {
+                throw new IllegalStateException("It is not possible to disable the sRGB color"
+                        + " space if PDF/A or PDF/X functionality is enabled or an"
+                        + " output profile is set!");
+            }
+        } else {
+            if (this.sRGBColorSpace != null) {
+                return;
+            }
+            //Map sRGB as default RGB profile for DeviceRGB
+            this.sRGBColorSpace = PDFICCBasedColorSpace.setupsRGBAsDefaultRGBColorSpace(pdfDoc);
         }
-        //Map sRGB as default RGB profile for DeviceRGB
-        this.sRGBColorSpace = PDFICCBasedColorSpace.setupsRGBAsDefaultRGBColorSpace(pdfDoc);
     }
     
     private void addDefaultOutputProfile() throws IOException {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java?rev=619417&r1=619416&r2=619417&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java Thu Feb  7 06:02:44 2008
@@ -24,6 +24,7 @@
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.pdf.PDFAMode;
@@ -80,6 +81,10 @@
             s = cfg.getChild(PDFRenderer.KEY_OUTPUT_PROFILE, true).getValue(null);
             if (s != null) {
                 pdfRenderer.setOutputProfileURI(s);
+            }
+            Configuration child = cfg.getChild(PDFRenderer.KEY_DISABLE_SRGB_COLORSPACE, false);
+            if (child != null) {
+                pdfRenderer.disableSRGBColorSpace = child.getValueAsBoolean(false);
             }
         }
     }

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=619417&r1=619416&r2=619417&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Thu Feb  7 06:02:44 2008
@@ -28,6 +28,10 @@
 
   <changes>
     <release version="FOP Trunk">
+      <action context="Fonts" dev="JM" type="add">
+        Added an option to disable the default sRGB profile in PDF output for those who
+        don't care about color fidelity, but care about PDF file size.
+      </action>
       <action context="Code" dev="AD" type="fix" fixes-bug="43705">
         Fixed a bug when the rgb-icc() function was used either before the fo:declarations,
         or in documents without a fo:declarations node. In such cases, the sRGB fallback

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/StandardTestSuite.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/StandardTestSuite.java?rev=619417&r1=619416&r2=619417&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/StandardTestSuite.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/StandardTestSuite.java Thu Feb  7 06:02:44 2008
@@ -19,14 +19,15 @@
  
 package org.apache.fop;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 import org.apache.fop.render.pdf.PDFAConformanceTestCase;
 import org.apache.fop.render.pdf.PDFCMapTestCase;
 import org.apache.fop.render.pdf.PDFEncodingTestCase;
+import org.apache.fop.render.pdf.PDFsRGBSettingsTestCase;
 import org.apache.fop.render.rtf.RichTextFormatTestSuite;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 /**
  * Test suite for basic functionality of FOP.
  */
@@ -45,6 +46,7 @@
         suite.addTest(new TestSuite(PDFAConformanceTestCase.class));
         suite.addTest(new TestSuite(PDFEncodingTestCase.class));
         suite.addTest(new TestSuite(PDFCMapTestCase.class));
+        suite.addTest(new TestSuite(PDFsRGBSettingsTestCase.class));
         suite.addTest(RichTextFormatTestSuite.suite());
         //$JUnit-END$
         return suite;

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java?rev=619417&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java (added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java Thu Feb  7 06:02:44 2008
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.pdf;
+
+import java.io.File;
+
+import org.apache.fop.apps.FOUserAgent;
+
+/**
+ * Tests the disables-srgb-colorspace setting.
+ */
+public class PDFsRGBSettingsTestCase extends BasePDFTestCase {
+
+    private File foBaseDir = new File("test/xml/pdf-a");
+
+    /**
+     * Main constructor
+     * @param name name of the test case
+     */
+    public PDFsRGBSettingsTestCase(String name) {
+        super(name);
+    }
+
+    private FOUserAgent getUserAgent(boolean enablePDFA) {
+        final FOUserAgent a = fopFactory.newFOUserAgent();
+        if (enablePDFA) {
+            a.getRendererOptions().put("pdf-a-mode", "PDF/A-1b");
+        }
+        a.getRendererOptions().put("disable-srgb-colorspace", Boolean.TRUE);
+        return a;
+    }
+    
+    /**
+     * Verify that the PDFRenderer complains if PDF/A or PDF/X is used when sRGB is disabled.
+     * @throws Exception if the test fails
+     */
+    public void testPDFAWithDisabledSRGB() throws Exception {
+        File foFile = new File(foBaseDir, "minimal-pdf-a.fo");
+        try {
+            convertFO(foFile, getUserAgent(true), false);
+            fail("PDFRenderer must fail if PDF/A is active!");
+        } catch (IllegalStateException e) {
+            //exception expected!
+        }
+    }
+    
+}

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

Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Id



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