If there's no owner password, then there aren't any restrictions on the PDF in terms of whether printing is allowed, text extraction, etc. So your code is doing exactly as you intend it to.
--Adam Faisal Farooq <ffar...@gmail.com> 11/04/2009 09:03 Please respond to pdfbox-users@incubator.apache.org To pdfbox-users@incubator.apache.org cc Subject Re: PDF Permissions I did check that the securityhandler is null. This is because I am not trying to decrypt the document at all and thus it is null which makes sense and indeed it is returning owner permissions. But lets step back a second and look at my problem. I have a pdf i did not create and i do not have 'any' password (user or owner). the way the pdf was created that everybody can print it but do nothing else. All i want to know is what are the permissions on this pdf in a programmatic way. one can open this document and look at the properties to find the same thing out, so there must be a programmatic way to do that too. So, how could this be done? Faisal On Tue, Nov 3, 2009 at 3:20 PM, Faisal Farooq <ffar...@gmail.com> wrote: > 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.