Forum Stats

  • 3,816,896 Users
  • 2,259,247 Discussions
  • 7,893,584 Comments

Discussions

Access Permissions not reflecting on PDF Document Restriction Summary using PDFBox

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();


Tagged: