Free Support Forum - aspose.com

java.lang.IndexOutOfBoundsException: Invalid index in Rows indexer: -1

Hi Support Team,


I am using aspose.pdf 3.1.0 in java.

I am getting this exception when I try to save PDF file.

I wanted to know what is missing which causes this exception.(or when generally it comes)

I am creating columns and then populating rows .This happens when I create new section in same pdf and again create columns and populate rows.(For first section it works good ,when I go for second it fails)

Any help will be appreciated.

Thanks and Best regards,
Ankit

Hi Ankit,


Thanks for using our products.

Can you please share some code snippet which can help us in replicating this issue so that we can test the scenario at our end. We are sorry for this inconvenience.

Hi


This is happeing when I set table.setColumnAdjustment(ColumnAdjustmentType.AutofitToContent);

if I do it
table.setColumnAdjustment(ColumnAdjustmentType.Customized);

it doesnt happen

Ankit

Ankit777:
This is happeing when I set table.setColumnAdjustment(ColumnAdjustmentType.AutofitToContent);

if I do it
table.setColumnAdjustment(ColumnAdjustmentType.Customized);
Hi Ankit,

Thanks for sharing the details.

I have tested the scenario using Aspose.Pdf for Java 3.3.0 and I am unable to notice any issue while generating the PDF file. I have tested the scenario over Windows 7 (X64) where I have used JDK 1.7. I have used the following code snippet to test the scenario. Can you please try using the latest release version and in case the problem still persists, please feel free to contact.

[Java]

Pdf pdf1 = new Pdf();<o:p></o:p>

Section sec1 = pdf1.getSections().add();

aspose.pdf.Table table1 = new aspose.pdf.Table();

sec1.getParagraphs().add(table1);

table1.setColumnWidths("70 2cm");

table1.setColumnAdjustment(ColumnAdjustmentType.Customized);

Row row1 = table1.getRows().add();

Cell cell1Row1 = row1.getCells().add("ColumnsSpan = 2");

cell1Row1.setColumnsSpan(2);

cell1Row1.setBorder(new BorderInfo(BorderSide.All.getValue(), 0.5F));

Row row2 = table1.getRows().add();

Cell cell1Row2 = row2.getCells().add("cell1");

cell1Row2.setBorder(new BorderInfo(BorderSide.All.getValue(), 0.5F));

Cell cell2Row2 = row2.getCells().add("cell2");

cell2Row2.setBorder(new BorderInfo(BorderSide.All.getValue(), 0.5F, new aspose.pdf.Color("Red")));

Section sec2 = pdf1.getSections().add();

aspose.pdf.Table table2 = new aspose.pdf.Table();

sec2.getParagraphs().add(table2);

table2.setColumnWidths("70 2cm");

table2.setColumnAdjustment(ColumnAdjustmentType.Customized);

Row row12 = table2.getRows().add();

Cell cell1Row12 = row12.getCells().add("ColumnsSpan = 2");

cell1Row12.setColumnsSpan(2);

cell1Row12.setBorder(new BorderInfo(BorderSide.All.getValue(), 0.5F));

Row row22 = table2.getRows().add();

Cell cell1Row22 = row22.getCells().add("cell1");

cell1Row22.setBorder(new BorderInfo(BorderSide.All.getValue(), 0.5F));

Cell cell2Row23 = row22.getCells().add("cell2");

cell2Row23.setBorder(new BorderInfo(BorderSide.All.getValue(), 0.5F, new aspose.pdf.Color("Red")));

pdf1.save(“c:/pdftest/Exception_Reproduce.pdf”);