Free Support Forum - aspose.com

AutoFiller array index out of bounds

I'm using AutoFiller in a manner similar to case 3 in the AutoFilling.java sample. I keep getting array index out of bounds errors on the autoFiller.importData statement. It's always one more than the number of columns. The stacktrace points to a Vector issue. I've examined my code over and over. The Vectors I'm providing are filled correctly. They are also sized correctly. If I arbitrarily increase the size of the Vectors without providing any more data I get a null pointer exception on the importData. What do I have to do to satisfy ImportData?

Best,

Clif...

Dear Clif,

Thanks for considering Aspose.Pdf.Kit for Java.

Would you please share your code as well as PDF template for problem reproducing? We will help you solve it ASAP.

Best regards.

I've uploaded the pdf. For various reasons sending you the source is not practical. You could not test it even if I sent it to you. Could you just give me some clues as to what would cause this?

Best,

Clif...

Dear Clif,

We will test with it and show you the result. What we need is your operation information, we do not need the complete project to run. Anyway, Thanks a lot.

Best regards.

Luke,

You will be unable to test this. It is written in VB but references the Java classes. We compile the VB into Java classes. The Mono compiler does a good job of translating. It also runs in .Net. Here it is anyway.

Best,

Clif...

Dear Clif,

Thanks for your resource sharing. We analyzed your code and tested with your PDF template. Unfortunately, everything is OK. Please test my code in your platform and tell me the result.

try {
String path = TestPath + "gemini_temp\\";
Vector columnName = new Vector();
columnName.add("ID");
columnName.add("Category");

Vector rowData1 = new Vector();
rowData1.add("1");
rowData1.add("Beverages");
Vector rowData2 = new Vector();
rowData2.add("2");
rowData2.add("Condiments");
Vector rowData3 = new Vector();
rowData3.add("3");
rowData3.add("Confections");
Vector rowData4 = new Vector();
rowData4.add("4");
rowData4.add("Dairy Products");
Vector rowData5 = new Vector();
rowData5.add("5");
rowData5.add("Grains");
Vector rowData6 = new Vector();
rowData6.add("6");
rowData6.add("Meat");

Vector dataSource = new Vector();
dataSource.add(rowData1);
dataSource.add(rowData2);
dataSource.add(rowData3);
dataSource.add(rowData4);
dataSource.add(rowData5);
dataSource.add(rowData6);

String fileName = path + "testForm3.pdf";
try {
AutoFiller pdfAutoFiller = new AutoFiller(columnName, dataSource);
pdfAutoFiller.setGenMultiPdfs(false);
pdfAutoFiller.setBasicPath(path);
pdfAutoFiller.setInputFile(fileName);
pdfAutoFiller.setOutStream(new FileOutputStream(path +"testForm3.out.pdf"));

Form form = new Form(fileName);
String[] fieldNames = form.getFieldsNames();
for (int i = 0; i < fieldNames.length; i++) {
pdfAutoFiller.unFlatten(fieldNames[i]);
}
pdfAutoFiller.importData();
pdfAutoFiller.close();
}
catch (Exception ex) {
System.out.println(ex.toString());
}

}
catch (Exception ex) {
System.out.println(ex.toString());
}

Please make sure that right values were assigned to the vector parameters. Thanks & Best regards.

Dear Clif,

That is very strange. The code ran well in my platform. I am not sure whether you downloaded the latest version 2.0. Please confirm it and tell me the result. I will continue this issue until it has been resolved.

BTW, a new release 2.1 will be published soon. Please try after that.

Luke,

The problem went away when I installed 2.0. Apparently this was a 1.9 issue. Thank you for your support.

Best,

Clif...

Dear Clif,

Glad to hear that. Any other question is also welcomed!

Best regards.