PdfReader reader = new PdfReader("/STORE/F16.pdf");
FileOutputStream fout = new FileOutputStream("/STORE/F16-signed.pdf");
PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0');
stp.setEncryption(...);
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null,
PdfSignatureAppearance.WINCER_SIGNED);
Paulo
> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
> Sent: Tuesday, July 07, 2009 4:30 PM
> To: [email protected]
> Subject: [iText-questions] PDF Protection and Signing with iText
>
> 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
>
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer:
This message is destined exclusively to the intended receiver. It may contain
confidential or legally protected information. The incorrect transmission of
this message does not mean the loss of its confidentiality. If this message is
received by mistake, please send it back to the sender and delete it from your
system immediately. It is forbidden to any person who is not the intended
receiver to use, distribute or copy any part of this message.
------------------------------------------------------------------------------
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/