I create a pdf document and specify few acro-fields. These acro-fields used to be filled by java itext library. This document is digitally signed after adding all required acro-fields.
We already set form filling property in digital signature but whenever we are trying to fill this documents by itext library, this document's digital signature becomes invalid.
Here is the code that I am using to fill this document -
String FILE = "/Users/mahensha/Desktop/NOC/test1.pdf";
PdfReader reader = new PdfReader("/Users/mahensha/Desktop/NOC/test.pdf");
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(FILE));
AcroFields form = stamper.getAcroFields();
System.out.println("form: " + form);
form.setField("SellerName", "Mr.Mahendra Kumar Sharma");
form.setField("AddressLine1", "My address");
stamper.setFormFlattening(true);
stamper.close();
reader.close();
I am using lowagie itext library for filling pdf form.
Is there any way to fix this issue. Thanks.
PdfStamper
constructor with 4 parameters and usetrue
in the final one. That selects append mode which is required to not break existing signatures. – mkl