From 136e3cfdd77d227ae53ea4f84b3f5e21c1773b18 Mon Sep 17 00:00:00 2001 From: Luis Bernardo Date: Fri, 18 Jul 2014 23:05:19 +0000 Subject: [PATCH] FOP-2395: PDF encryption does not work when PDF version is set in FOP config; change suggested by Seifeddine Dridi. 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 | 4 +++- src/java/org/apache/fop/pdf/VersionController.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/fop/pdf/PDFDocument.java b/src/java/org/apache/fop/pdf/PDFDocument.java index a8d3d10c0..468d2f1c1 100644 --- a/src/java/org/apache/fop/pdf/PDFDocument.java +++ b/src/java/org/apache/fop/pdf/PDFDocument.java @@ -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() + "."); diff --git a/src/java/org/apache/fop/pdf/VersionController.java b/src/java/org/apache/fop/pdf/VersionController.java index bd5e4d20f..d9c024515 100644 --- a/src/java/org/apache/fop/pdf/VersionController.java +++ b/src/java/org/apache/fop/pdf/VersionController.java @@ -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 -- 2.39.5