Subhrajyoti Moitra
2009-02-10 16:10:41 UTC
Hi,
I am trying to unlock the attached PDF using the code snippet below.
public static void main(String[] args) throws Exception{
String
inputfile="C:\\SD\\User\\workspace\\Projects\\pdfapp-extension\\WebContent\\test_forms\\79954.pdf";
String
outputFile=System.getProperty("java.io.tmpdir")+File.separator+System.currentTimeMillis()+"_sourcePdf.pdf";
PdfReader sourcePdfFileReader=new PdfReader(inputfile);
if(!sourcePdfFileReader.isOpenedWithFullPermissions()){
System.out.println("This is encrypted and not will full
permissions.");
PdfEncryptor.encrypt(sourcePdfFileReader, new
FileOutputStream(outputFile), null,
null, PdfWriter.ALLOW_ASSEMBLY | PdfWriter.ALLOW_COPY
| PdfWriter.ALLOW_DEGRADED_PRINTING |
PdfWriter.ALLOW_FILL_IN
| PdfWriter.ALLOW_MODIFY_ANNOTATIONS |
PdfWriter.ALLOW_MODIFY_CONTENTS
| PdfWriter.ALLOW_PRINTING |
PdfWriter.ALLOW_SCREENREADERS, false);
}
sourcePdfFileReader.close();
}
This is giving me an exception
Exception in thread "main" java.lang.IllegalArgumentException: PdfReader not
opened with owner password
I read in this link, this is possible: http://www.ensode.net/pdf_unlock.html
Please help...
Thanks,
Subhro.
I am trying to unlock the attached PDF using the code snippet below.
public static void main(String[] args) throws Exception{
String
inputfile="C:\\SD\\User\\workspace\\Projects\\pdfapp-extension\\WebContent\\test_forms\\79954.pdf";
String
outputFile=System.getProperty("java.io.tmpdir")+File.separator+System.currentTimeMillis()+"_sourcePdf.pdf";
PdfReader sourcePdfFileReader=new PdfReader(inputfile);
if(!sourcePdfFileReader.isOpenedWithFullPermissions()){
System.out.println("This is encrypted and not will full
permissions.");
PdfEncryptor.encrypt(sourcePdfFileReader, new
FileOutputStream(outputFile), null,
null, PdfWriter.ALLOW_ASSEMBLY | PdfWriter.ALLOW_COPY
| PdfWriter.ALLOW_DEGRADED_PRINTING |
PdfWriter.ALLOW_FILL_IN
| PdfWriter.ALLOW_MODIFY_ANNOTATIONS |
PdfWriter.ALLOW_MODIFY_CONTENTS
| PdfWriter.ALLOW_PRINTING |
PdfWriter.ALLOW_SCREENREADERS, false);
}
sourcePdfFileReader.close();
}
This is giving me an exception
Exception in thread "main" java.lang.IllegalArgumentException: PdfReader not
opened with owner password
I read in this link, this is possible: http://www.ensode.net/pdf_unlock.html
Please help...
Thanks,
Subhro.