Index was outside the bounds of the array error

Index was outside the bounds of the array error

Forum member · Oct 3, 2008
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.

Re: Index was outside the bounds of the array error

Support · Oct 3, 2008
With this new PDF that you are using are you able to Merge and then Draw the file without filling in any form fields? In other words if you run your code without filling in any form fields do you still get the error? The first thing I want to make sure you have is the very latest dll file. Go ahead and log into the Customer Area of our site, http://www.DynamicPDF.com/CustomerArea with your serial number and download the latest build. This will verify that this is not related to any issues that have already been identified and fixed. If you get the latest build and make a new reference in your application and are still gettig the same issue then what we would need to do is take a look at the actual PDF document that you are using for the Merge (I do not see anything directly bad in the code you sent over). Send the PDF over to [^a|mailto:support@cete.com|support@cete.com^] along with the above information (the error stack trace and the source code). Also put in there the actual build number of the dll you are using now. From that we will be able to take a look into this further. Thanks, ceTe Software Support Team

Re: Index was outside the bounds of the array error

Forum member · Oct 6, 2008
I created a simple test console app. It easily blew up with the same error when it came to the Draw method (but no form-filling). Next, I download and installed the latest dll, as you suggested. I was on Build 70913 and the latest one I got from the CustomerArea on the website was 80214. I reran my test app, and it worked! Thanks so much. ... However, I am curious. After reading a couple other somewhat similar posts, I was worried I had a "corrupted" PDF, even though Reader and Pro and Designer could all open it and deal with the form fields. Any information you could share on what the underlying issue was? Or should I just be content with the new DLL? <g> Thanks again.

Re: Index was outside the bounds of the array error

Support · Oct 6, 2008
Hello, Some PDF documents are corrupt and our product is little strict in allowing merging of corrupt PDF documents. You can refer to the version notes on our web site that show the issues fixed in each version. The error message is more generic error message, so we are not sure of the underlying problem that could be causing this exception in your case. Thanks, ceTe Software Support Team