aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Cumiskey <acumiskey@apache.org>2008-07-07 12:42:12 +0000
committerAdrian Cumiskey <acumiskey@apache.org>2008-07-07 12:42:12 +0000
commitb7948c5519c5dee7f6c60f5159ee0b7d6631f856 (patch)
tree3fbab812ba4d0d89722aab59fa5195f8c1ba4002
parent6b9a616033d0278cd3c4734ac6e6a227a934f547 (diff)
downloadxmlgraphics-fop-b7948c5519c5dee7f6c60f5159ee0b7d6631f856.tar.gz
xmlgraphics-fop-b7948c5519c5dee7f6c60f5159ee0b7d6631f856.zip
Added PDF encryption parameter support in configuration.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@674471 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/documentation/content/xdocs/trunk/configuration.xml21
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java48
-rw-r--r--status.xml3
3 files changed, 69 insertions, 3 deletions
diff --git a/src/documentation/content/xdocs/trunk/configuration.xml b/src/documentation/content/xdocs/trunk/configuration.xml
index e82a6e862..8d6b1f1c8 100644
--- a/src/documentation/content/xdocs/trunk/configuration.xml
+++ b/src/documentation/content/xdocs/trunk/configuration.xml
@@ -294,6 +294,27 @@
<fonts....
</renderer>]]></source>
+
+ <p>FOP supports encryption of PDF output, thanks to Patrick C. Lankswert.
+ This feature is commonly used to prevent unauthorized viewing, printing, editing, copying text
+ from the document and doing annotations. It is also possible to ask the user for a password in
+ order to view the contents. Note that there already exist third party applications which can
+ decrypt an encrypted PDF without effort and allow the aforementioned operations, therefore the
+ degree of protection is limited. For further information about features and restrictions
+ regarding PDF encryption, look at the documentation coming with Adobe Acrobat or the technical
+ documentation on the Adobe web site.</p>
+ <source><![CDATA[
+ <renderer mime="application/pdf">
+ <encryption-params>
+ <user-password>testuserpass</user-password>
+ <owner-password>testownerpass</owner-password>
+ <noprint/>
+ <nocopy/>
+ <noedit/>
+ <noannotations/>
+ </encryption-params>
+ </renderer>]]></source>
+
</section>
<section id="ps-renderer">
<title>Special Settings for the PostScript Renderer</title>
diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java b/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
index 2fce8859a..51e13dde1 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
@@ -28,6 +28,7 @@ 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;
+import org.apache.fop.pdf.PDFEncryptionParams;
import org.apache.fop.pdf.PDFFilterList;
import org.apache.fop.pdf.PDFXMode;
import org.apache.fop.render.PrintRendererConfigurator;
@@ -78,13 +79,54 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator {
if (s != null) {
pdfRenderer.setXMode(PDFXMode.valueOf(s));
}
+ Configuration encryptionParamsConfig = cfg.getChild(PDFRenderer.ENCRYPTION_PARAMS, false);
+ if (encryptionParamsConfig != null) {
+ PDFEncryptionParams encryptionParams = new PDFEncryptionParams();
+ Configuration ownerPasswordConfig = encryptionParamsConfig.getChild(
+ PDFRenderer.OWNER_PASSWORD, false);
+ if (ownerPasswordConfig != null) {
+ String ownerPassword = ownerPasswordConfig.getValue(null);
+ if (ownerPassword != null) {
+ encryptionParams.setOwnerPassword(ownerPassword);
+ }
+ }
+ Configuration userPasswordConfig = encryptionParamsConfig.getChild(
+ PDFRenderer.USER_PASSWORD, false);
+ if (userPasswordConfig != null) {
+ String userPassword = userPasswordConfig.getValue(null);
+ if (userPassword != null) {
+ encryptionParams.setUserPassword(userPassword);
+ }
+ }
+ Configuration noPrintConfig = encryptionParamsConfig.getChild(
+ PDFRenderer.NO_PRINT, false);
+ if (noPrintConfig != null) {
+ encryptionParams.setAllowPrint(false);
+ }
+ Configuration noCopyContentConfig = encryptionParamsConfig.getChild(
+ PDFRenderer.NO_COPY_CONTENT, false);
+ if (noCopyContentConfig != null) {
+ encryptionParams.setAllowCopyContent(false);
+ }
+ Configuration noEditContentConfig = encryptionParamsConfig.getChild(
+ PDFRenderer.NO_EDIT_CONTENT, false);
+ if (noEditContentConfig != null) {
+ encryptionParams.setAllowEditContent(false);
+ }
+ Configuration noAnnotationsConfig = encryptionParamsConfig.getChild(
+ PDFRenderer.NO_ANNOTATIONS, false);
+ if (noAnnotationsConfig != null) {
+ encryptionParams.setAllowEditAnnotations(false);
+ }
+ pdfRenderer.setEncryptionParams(encryptionParams);
+ }
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);
+ Configuration disableColorSpaceConfig = cfg.getChild(PDFRenderer.KEY_DISABLE_SRGB_COLORSPACE, false);
+ if (disableColorSpaceConfig != null) {
+ pdfRenderer.disableSRGBColorSpace = disableColorSpaceConfig.getValueAsBoolean(false);
}
}
}
diff --git a/status.xml b/status.xml
index 20caa0e1a..5bbcd4bd1 100644
--- a/status.xml
+++ b/status.xml
@@ -53,6 +53,9 @@
<changes>
<release version="FOP Trunk" date="TBD">
+ <action context="Renderers" dev="AC" type="add">
+ Added PDF encryption parameter support in configuration.
+ </action>
<action context="Layout" dev="LF" type="add">
Allowing non-zero borders and padding on page regions when
relaxed validation is turned on.