I am using iText to fill pdf form, no error in console, but when i am opening the output pdf it is giving "Expected a dict object" and after it gives another message saying "This document enabled extended features in Adobe reader. The document has been changed since it was created and use of extended features is no longer available."
Also the output pdf have the changes i made but it does not have features of original pdf document, as the above message shows.
I have used below code...
PdfReader reader = new PdfReader("C:\\Users\\asfs\\Downloads\\1013-Form22.pdf");
String name = "C:\\Users\\asfs\\Downloads\\Temp.pdf";
PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(name));
AcroFields form = stamp.getAcroFields();
String last = "Form22_Dtls[0].Page1[0].Country_C[0]";
form.setField(last, "Sample Country name");
HashMap map = new HashMap();
map = form.getFields();
Iterator iterator = map.keySet().iterator();
while(iterator.hasNext())
System.out.println("Field is >>>"+iterator.next());
// close pdf stamper
stamp.setFormFlattening(true);
stamp.close();
Please help me.
Thanks
Try:
// open the pdf stamper in edit mode
stamp = new PdfStamper(reader, new FileOutputStream(name), '\0', true);
The PdfStamper needs to be in append mode.