Hello Friends,

I'm stuck at an issue with my code. I want to protect a PDF( User is Allowed to print only) and then Sign it. When tried to do so, i got an exception "com.lowagie.text.DocumentException: The original document was reused. Read it again from file."


My code is some thing like below

PdfReader reader = new PdfReader("/STORE/F16.pdf");
FileOutputStream fout = new FileOutputStream("/STORE/F16-signed.pdf");
PdfEncryptor.encrypt(reader,
fout,
null,
null,PdfWriter.AllowPrinting ,PdfWriter.STRENGTH128BITS);
PdfReader readerCpy = new PdfReader("/STORE/F16-signed.pdf");
PdfStamper stp = PdfStamper.createSignature(readerCpy, fout, '\0');
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null,
PdfSignatureAppearance.WINCER_SIGNED);



So, I made another try, by introducing a temporary file in between.

...............................................................................
PdfReader reader = new PdfReader("/STORE/F16.pdf");
FileOutputStream fout = new FileOutputStream("/STORE/F16-signed_temp.pdf");
PdfEncryptor.encrypt(reader,
fout,
null,
null,PdfWriter.AllowPrinting ,PdfWriter.STRENGTH128BITS);

fout.close();
reader.close();
PdfReader readerCpy = new PdfReader("/STORE/F16-signed_temp.pdf");
FileOutputStream fout = new FileOutputStream("/STORE/F16-signed.pdf");
PdfStamper stp = PdfStamper.createSignature(readerCpy, fout, '\0');
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null,
PdfSignatureAppearance.WINCER_SIGNED);


But in this attempt, while reading the encrypted file , I lost the encryption properties which I want to preserve before signing.

Please guide me to solve this issue, i'm facing this issue with iText-1.3.1 and iText-2.1.4
Regards,
Santhosh
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have 
the opportunity to enter the BlackBerry Developer Challenge. See full prize 
details at: http://p.sf.net/sfu/blackberry
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to