I'm having a problem saving
PDF form text field values that I populated using iText. The code below
opens a PDF file for input and creates another for output with the updated text
field values. The problem is when I open the output PDF file I get the
error message "Wrong type parameter supplied to a PDS procedure". Once I
clear the error message box I can view the document with the correct
updated field values. Below is the sample code. Is this the correct
way to update a text field and save the changes to a PDF?
PdfReader reader1 =
new PdfReader("InputForm.pdf");File updatedPDF = new File("UpdatedForm.pdf");
PdfStamper pdfStamper = new PdfStamper(reader1, new FileOutputStream(updatedPDF.getAbsolutePath()));
AcroFields acroFields = pdfStamper.getAcroFields();
HashMap PDFFields = acroFields.getFields();
Set fieldNameKeys = PDFFields.keySet();
for ( Iterator fieldNames = fieldNameKeys.iterator(); fieldNames.hasNext(); ){
String fieldName = (String)fieldNames.next();
if ( fieldName.indexOf("ApplicantName") != -1){
boolean isApplicantNameFieldUpdated = acroFields.setField( fieldName, "Russell Burke");
boolean isApplicantNameFieldFlattened = pdfStamper.partialFormFlattening(fieldName);
}
}
pdfStamper.setFormFlattening(
true);pdfStamper.close();
Thanks,
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
