]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2395: PDF encryption does not work when PDF version is set in FOP config; change...
authorLuis Bernardo <lbernardo@apache.org>
Fri, 18 Jul 2014 23:05:19 +0000 (23:05 +0000)
committerLuis Bernardo <lbernardo@apache.org>
Fri, 18 Jul 2014 23:05:19 +0000 (23:05 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1611834 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/pdf/PDFDocument.java
src/java/org/apache/fop/pdf/VersionController.java

index a8d3d10c0fbdcc9e238607312d86a01b431a33f8..468d2f1c1ec54d66f326601e6fb2ca03f92893af 100644 (file)
@@ -543,7 +543,9 @@ public class PDFDocument {
             PDFObject pdfObject = (PDFObject)this.encryption;
             addTrailerObject(pdfObject);
             try {
-                versionController.setPDFVersion(encryption.getPDFVersion());
+                if (encryption.getPDFVersion().compareTo(versionController.getPDFVersion()) > 0) {
+                    versionController.setPDFVersion(encryption.getPDFVersion());
+                }
             } catch (IllegalStateException ise) {
                 log.warn("Configured encryption requires PDF version " + encryption.getPDFVersion()
                         + " but version has been set to " + versionController.getPDFVersion() + ".");
index bd5e4d20f05687be01b5f42951efd3676675eac1..d9c024515b5fd88d300ef4995f994acb70dc78fe 100644 (file)
@@ -69,7 +69,9 @@ public abstract class VersionController {
 
         @Override
         public void setPDFVersion(Version version) {
-            throw new IllegalStateException("Cannot change the version of this PDF document.");
+            if (super.version.compareTo(version) != 0) {
+                throw new IllegalStateException("Cannot change the version of this PDF document.");
+            }
         }
 
         @Override