Skip to Main Content

Java User Groups

Announcement

Testing banner

Access Permissions not reflecting on PDF Document Restriction Summary using PDFBox

User_40C6QFeb 23 2022

Hi All, I'm using PDFBox for PDF encryption. There is a requirement to set all the Document Restriction Summary fields to "Not Allowed". I'm using the below code to set the permissions. But these are not reflecting on PDF Document Restriction Summary. I'm missing anything here. Is it possible to change the field values with pdfbox? pls help.
AccessPermission ap = new AccessPermission();
ap.setCanAssembleDocument(false);
ap.setCanExtractContent(false);
ap.setCanExtractForAccessibility(false);
ap.setCanFillInForm(false);
ap.setCanModify(false);
ap.setCanModifyAnnotations(false);
ap.setCanPrint(false);
ap.setCanPrintDegraded(false);
ap.setReadOnly();
StandardProtectionPolicy spp = new StandardProtectionPolicy(userPassword, globalPassword, ap);
spp.setPermissions(ap);
spp.setEncryptionKeyLength(128);
pddocument.protect(spp);
pddocument.save(outputpdf);
pddocument.close();
image.png

Comments
Post Details
Added on Feb 23 2022
0 comments
71 views