You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2021/01/16 12:54:08 UTC

svn commit: r1885560 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java

Author: tilman
Date: Sat Jan 16 12:54:07 2021
New Revision: 1885560

URL: http://svn.apache.org/viewvc?rev=1885560&view=rev
Log:
PDFBOX-4892: improve javadoc - people should not use PDDocument after saving encrypted because it's encrypted

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java?rev=1885560&r1=1885559&r2=1885560&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java Sat Jan 16 12:54:07 2021
@@ -877,7 +877,11 @@ public class PDDocument implements Close
     
     /**
      * Save the document to a file using default compression.
-     * 
+     * <p>
+     * If encryption has been activated (with
+     * {@link #protect(org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy) protect(ProtectionPolicy)}),
+     * do not use the document after saving because the contents are now encrypted.
+     *
      * @param fileName The file to save as.
      *
      * @throws IOException if the output could not be written
@@ -889,6 +893,10 @@ public class PDDocument implements Close
 
     /**
      * Save the document to a file using default compression.
+     * <p>
+     * If encryption has been activated (with
+     * {@link #protect(org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy) protect(ProtectionPolicy)}),
+     * do not use the document after saving because the contents are now encrypted.
      * 
      * @param file The file to save as.
      *
@@ -901,6 +909,10 @@ public class PDDocument implements Close
 
     /**
      * This will save the document to an output stream.
+     * <p>
+     * If encryption has been activated (with
+     * {@link #protect(org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy) protect(ProtectionPolicy)}),
+     * do not use the document after saving because the contents are now encrypted.
      *
      * @param output The stream to write to. It is recommended to wrap it in a {@link java.io.BufferedOutputStream},
      * unless it is already buffered.
@@ -914,6 +926,10 @@ public class PDDocument implements Close
 
     /**
      * Save the document using the given compression.
+     * <p>
+     * If encryption has been activated (with
+     * {@link #protect(org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy) protect(ProtectionPolicy)}),
+     * do not use the document after saving because the contents are now encrypted.
      *
      * @param file The file to save as.
      * @param compressParameters The parameters for the document's compression.
@@ -930,6 +946,10 @@ public class PDDocument implements Close
 
     /**
      * Save the document to a file using the given compression.
+     * <p>
+     * If encryption has been activated (with
+     * {@link #protect(org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy) protect(ProtectionPolicy)}),
+     * do not use the document after saving because the contents are now encrypted.
      * 
      * @param fileName The file to save as.
      * @param compressParameters The parameters for the document's compression.
@@ -943,6 +963,10 @@ public class PDDocument implements Close
 
     /**
      * Save the document using the given compression.
+     * <p>
+     * If encryption has been activated (with
+     * {@link #protect(org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy) protect(ProtectionPolicy)}),
+     * do not use the document after saving because the contents are now encrypted.
      *
      * @param output The stream to write to. It is recommended to wrap it in a {@link java.io.BufferedOutputStream},
      * unless it is already buffered.
@@ -1185,6 +1209,8 @@ public class PDDocument implements Close
      * encrypted when it will be saved. This method only marks the document for encryption. It also
      * calls {@link #setAllSecurityToBeRemoved(boolean)} with a false argument if it was set to true
      * previously and logs a warning.
+     * <p>
+     * Do not use the document after saving, because the structures are encrypted.
      *
      * @see org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy
      * @see org.apache.pdfbox.pdmodel.encryption.PublicKeyProtectionPolicy