Instantly share code, notes, and snippets.

@mgohin /ChecklistHelper.java Secret
Last active Nov 23, 2016

Embed
What would you like to do?
private void protectDocument(PDDocument pdfDocument) throws IOException {
AccessPermission ap = new AccessPermission();
ap.setCanModify(false);
ap.setCanExtractContent(false);
ap.setCanFillInForm(false);
ap.setCanPrint(true);
ap.setReadOnly();
StandardProtectionPolicy spp = new StandardProtectionPolicy(UUID.randomUUID().toString(), "", ap);
spp.setEncryptionKeyLength(128);
spp.setPermissions(ap);
pdfDocument.protect(spp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment