Get Document Privileges
Contents
[
Hide
]
Get document privileges
Use PdfFileInfo.getDocumentPrivilege() to inspect what operations the current PDF allows.
Steps
- Create a
PdfFileInfoobject for the input PDF. - Call
getDocumentPrivilege()to retrieve the privilege set. - Read the relevant boolean flags from the returned
DocumentPrivilegeobject. - Close the
PdfFileInfoinstance when finished.
Java example
public static void getDocumentPrivileges(Path inputFile) {
PdfFileInfo pdfInfo = new PdfFileInfo(inputFile.toString());
DocumentPrivilege privileges = pdfInfo.getDocumentPrivilege();
System.out.println("Document Privileges:");
System.out.println(" Can Print: " + privileges.isAllowPrint());
System.out.println(" Can Degraded Print: " + privileges.isAllowDegradedPrinting());
System.out.println(" Can Copy: " + privileges.isAllowCopy());
System.out.println(" Can Modify Contents: " + privileges.isAllowModifyContents());
System.out.println(" Can Modify Annotations: " + privileges.isAllowModifyAnnotations());
System.out.println(" Can Fill In: " + privileges.isAllowFillIn());
System.out.println(" Can Screen Readers: " + privileges.isAllowScreenReaders());
System.out.println(" Can Assembly: " + privileges.isAllowAssembly());
pdfInfo.close();
}