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
>

Reply via email to