Hi All,
i wrote a small piece of code, nothing complicated. But it does not seem to
work. The code simply prints the message whether the PDF is secured against
extraction or not. I tried it with both secure and non-secure PDFs but it
always returns a true for
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