Hi Guys,
I have been playing with iText signing and
encryption functionality for some time and below are my obervations using
iText-50
- For multiple signings to work the last parameter MUST be set to true other wise signing again will corrupt the previous signatures.
PdfStamper stp =
PdfStamper.createSignature(reader, fout, '\0', new java.io.File("temp1"),
true);
- For Sign & Encrypting a PDF that parameter MUST be set to 'false', other wise an exception will come i.e.
com.lowagie.text.DocumentException: Append mode does not support encryption.at com.lowagie.text.pdf.PdfStamper.setEncryption(PdfStamper.java:302)at com.lowagie.text.pdf.PdfStamper.setEncryption(PdfStamper.java:322)PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0', new java.io.File("temp1"), false);
- While signing and encrypting using the 'false' parameter as above the previous signature if present gets corrupted. A more detailed result is as follows:
PDF document state Action to Perform Are Previous signatures get corrupted ?-----------------------------------------------------------------------------------------------------------------------------------------Sign&Enc Sign YESSign Sign&Enc YESEnc Sign&Enc NoEnc Sign No
Q1) Can we do some thing to change YES to No in the above table
?
Q2) Also is there an easy
way to figure out whether a PDF document is already encrypted
without catching certain exceptions ?
Regards,
Wahaj
