aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/pdf
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-02-07 14:02:44 +0000
committerJeremias Maerki <jeremias@apache.org>2008-02-07 14:02:44 +0000
commit575826b283fa659929204c63905e05fe2e2cf5f5 (patch)
tree917b9bc7eebceb5e4dec3c5c33f1ad3576f6e2b4 /src/java/org/apache/fop/render/pdf
parent448befc115b005dc2a07391182179c686a91d25f (diff)
downloadxmlgraphics-fop-575826b283fa659929204c63905e05fe2e2cf5f5.tar.gz
xmlgraphics-fop-575826b283fa659929204c63905e05fe2e2cf5f5.zip
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!
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@619417 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/pdf')
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFRenderer.java31
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java5
2 files changed, 30 insertions, 6 deletions
diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
index 86c01f673..09c6fbed4 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
@@ -147,6 +147,11 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
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 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
/** 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 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
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 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
}
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 {
diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java b/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
index aec094e3b..2fce8859a 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
@@ -24,6 +24,7 @@ import java.util.Map;
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;
@@ -81,6 +82,10 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator {
if (s != null) {
pdfRenderer.setOutputProfileURI(s);
}
+ Configuration child = cfg.getChild(PDFRenderer.KEY_DISABLE_SRGB_COLORSPACE, false);
+ if (child != null) {
+ pdfRenderer.disableSRGBColorSpace = child.getValueAsBoolean(false);
+ }
}
}