We are using Merger to programmatically fill in a PDF form. So far so good. Unfortunately, I just updated the base form and now the same code that was working is now failing when the Draw method is called.
I am able to create a mergedocument, loop thru all the fields and set values successfully, but the Draw method throws the following exception:
System.IndexOutOfRangeException was unhandled
Message="Index was outside the bounds of the array."
Source="ceTe.DynamicPDF.20"
StackTrace:
at zz93.bu.j(Int32 A_0)
at zz93.bu.f(Int32 A_0)
at zz93.g7..ctor(ch A_0, Byte[] A_1, Int32 A_2)
at zz93.bu.a(ch A_0, Byte[] A_1, Int32 A_2)
at zz93.dj.a(ch A_0, Int32 A_1)
at zz93.fc.a(fu A_0)
at zz93.g1.a(DocumentWriter A_0)
at zz93.jz.a(DocumentWriter A_0)
at zz93.ip.a(DocumentWriter A_0)
at zz93.hl.b(DocumentWriter A_0)
at ceTe.DynamicPDF.Merger.Forms.PdfFormField.a(DocumentWriter A_0)
at zz93.gt.a(DocumentWriter A_0)
at ceTe.DynamicPDF.Forms.FormField.Draw(DocumentWriter writer)
at ceTe.DynamicPDF.IO.DocumentResourceList.a(DocumentWriter A_0)
at zz93.ab.v()
at ceTe.DynamicPDF.Document.Draw(String filePath)
InnerException:
Some code snippets:
//add pdf to merge document, tagging the form fields
MergeDocument mergeDoc = new MergeDocument();
mergeDoc.Append(pdfDoc, new MergeOptions(true));
FormFieldList fList = mergeDoc.Form.Fields;
//loop through field list
foreach (FormField f in fList)
{
//get field name
string sFieldName = f.Name;
//check for field name value in hashtable
if (formFieldValues.ContainsKey(sFieldName))
{
f.Value = PDFUtils.FormatDataObject(formFieldValues[sFieldName]);
}
}
.
.
.
mergeDoc.Draw(Path.GetFullPath(filePath));
That last statement, mergeDoc.Draw, is where it fails now.