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 ac...@apache.org on 2008/07/07 14:42:13 UTC

svn commit: r674471 - in /xmlgraphics/fop/trunk: src/documentation/content/xdocs/trunk/configuration.xml src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java status.xml

Author: acumiskey
Date: Mon Jul  7 05:42:12 2008
New Revision: 674471

URL: http://svn.apache.org/viewvc?rev=674471&view=rev
Log:
Added PDF encryption parameter support in configuration.

Modified:
    xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
    xmlgraphics/fop/trunk/status.xml

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=674471&r1=674470&r2=674471&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml (original)
+++ xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml Mon Jul  7 05:42:12 2008
@@ -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>

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=674471&r1=674470&r2=674471&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 Mon Jul  7 05:42:12 2008
@@ -28,6 +28,7 @@
 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 @@
             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);
             }
         }
     }

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=674471&r1=674470&r2=674471&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Mon Jul  7 05:42:12 2008
@@ -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.



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