wow... talk about miscommunication. Adam, the pdf 'HAS' a password. Its just that I do not know it. the password protects the security settings from being changed, so for example in case i want to change it security settings, i cannot as i do not know the password.
But my problem is not i want to change the settings. i do not want to decrypt the document. All i want is, given a pdf, i want to know what operations I am allowed to do on it as a user i.e. what are the operations that the pdf owner has allowed anybody who does not have know the password. If I can see those settings without a password by just going to File->Properties->Security, then I am not willing to accept that I cannot get the same information programmatically without knowing the password. Guys, am i being so difficult to understand??? Imagine a scenario - I attach a pdf in this email and Hesham gets the pdf. He can open and print it, but he cannot copy the content etc. because I am the owner and only I know the password and I have prevented access to content copying for everybody but I allowed people to print it. If Hesham opens the pdf in adobe and goes to File->Properties->Security, he knows what are the operations he is allowed to perform on the pdf. He does not know the password and does not require one to do this. Now, how can Hesham know the same information using a program rather than opening it in adobe and physically looking at the settings. Makes sense??? Faisal On Wed, Nov 4, 2009 at 12:03 PM, Faisal Farooq <ffar...@gmail.com> wrote: > 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 >> > >