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