You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2020/08/15 15:52:56 UTC

[pdfbox-docs] branch master updated: Update encryption.md

This is an automated email from the ASF dual-hosted git repository.

lehmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git


The following commit(s) were added to refs/heads/master by this push:
     new 5e6932a  Update encryption.md
     new b00a0fd  Merge pull request #3 from bibhas2/patch-1
5e6932a is described below

commit 5e6932a54efef830fd26f2a1c5580e6080a3ce28
Author: Bibhas Bhattacharya <bi...@gmail.com>
AuthorDate: Sat Aug 15 10:31:56 2020 -0400

    Update encryption.md
    
    The main change is that there is no need to call ``spp.setPermissions(ap);`` as the access permission object is already set in the constructor of ``StandardProtectionPolicy``.
    
    The other changes are minor enhancements:
    - Added ``ap.setCanExtractContent(false);`` as another example of protection
    - Added a few extra comments
---
 content/2.0/cookbook/encryption.md | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/content/2.0/cookbook/encryption.md b/content/2.0/cookbook/encryption.md
index 8370258..a850326 100644
--- a/content/2.0/cookbook/encryption.md
+++ b/content/2.0/cookbook/encryption.md
@@ -40,14 +40,18 @@ int keyLength = 256;
 
 AccessPermission ap = new AccessPermission();
 
-// disable printing, everything else is allowed
+// disable printing, 
 ap.setCanPrint(false);
+//disable copying
+ap.setCanExtractContent(false);
+//Disable other things if needed...
 
 // Owner password (to open the file with all permissions) is "12345"
 // User password (to open the file but with restricted permissions, is empty here)
 StandardProtectionPolicy spp = new StandardProtectionPolicy("12345", "", ap);
 spp.setEncryptionKeyLength(keyLength);
-spp.setPermissions(ap);
+
+//Apply protection
 doc.protect(spp);
 
 doc.save("filename-encrypted.pdf");