Your code looks fine. Trace the code and use some debug statements if necessary.
Start by looking at PDDocument. If this.securityHandler == null then getCurrentAccessPermission() will return AccessPermission.getOwnerAccessPermission(). If you look at getOwnerAccessPermission() you'll see why it always returns true. On the other hand, if it's returning the access permission from the securityHandler, then you'll have to trace a little more. --Adam Faisal Farooq <ffar...@gmail.com> 11/03/2009 12:20 Please respond to pdfbox-users@incubator.apache.org To pdfbox-users@incubator.apache.org cc Subject Fwd: PDF Permissions Hesham and Adam and All, My problem seems to be simpler in spirit. All i want to know are the security settings on a pdf. i do not have the password. i have a pdf file and i want to know what are the operations that are allowed on the pdf. It would be like opening the pdf in adobe and then going to File->Properties->Security and finding what is allowed and what is not. The code below does not seem to work. It always return the variable 'ex' as true, even if the PDF has Extraction Not Allowed set. Any ideas? ex = ap.canExtractContent() and thus always prints "You have permission to > extract text". > > Can anybody tell me what am I doing wrong? The file mypdf.pdf has all > settings except printing as 'Not Allowed'. > > ********** > > boolean force = false; > String pdfFile = "mypdf.pdf"; > > try { > document = PDDocument.load(pdfFile, force); > } catch (IOException e) { > System.out.println(e.getMessage()); > } > > AccessPermission ap = document.getCurrentAccessPermission(); > > boolean ex = ap.canExtractContent(); > > if( !ex ){ > System.out.println( "You do not have permission to extract > text" ); > } > else{ > System.out.println( "You have permission to extract text" ); > } > > ************* > > Faisal ? Click here to submit conditions This email and any content within or attached hereto from Sun West Mortgage Company, Inc. is confidential and/or legally privileged. The information is intended only for the use of the individual or entity named on this email. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or the taking of any action in reliance on the contents of this email information is strictly prohibited, and that the documents should be returned to this office immediately by email. Receipt by anyone other than the intended recipient is not a waiver of any privilege. Please do not include your social security number, account number, or any other personal or financial information in the content of the email. Should you have any questions, please call (800) 453 7884.