Argument exception when creating a PDF with a table

Hello,

I am using Aspose.Pdf.Generator.Pdf (6.9.0.0) to create a PDF with a table. When I save the pdf, I get the exception below. Do you know what the source of this exception could be? Is it a row I am setting up incorrectly?

2012-04-23 11:53:24,542 [10] ERROR CMS [(null)] - System.ArgumentException: Invalid index in Rows indexer: -1
at Aspose.Pdf.Generator.Rows.get_Item(Int32 index)
at .?.(Pdf doc, Section currentPart, Table table, Single availableHeight, Single& breakAreaHeight, Boolean rowInNewPage)
at .?.(Pdf doc, Section currentPart, HeaderFooter hf, Table table, assignInfo, bakAssignInfo,  useType, Boolean isFirst, & breakTableNextPart)
at .?.(Pdf doc, Section currentPart, HeaderFooter hf, Table table, assignInfo,  useType, Boolean isFirst, & breakTableNextPart)
at .?.(Pdf , Section , )
at ..(Pdf )
at .e.(? , Pdf )
at Aspose.Pdf.Generator.Pdf.Save(String pdfFile)

Hi James,

Thanks for using our products.

Can you please share some details regarding sample source code you are using or create a sample application to show the issue. This will help us to figure out the issue and reply back to you soon.

We apologize for your inconvenience.

Thanks & Regards,

Sure. It only happens when the table extends beyond one page:


Aspose.Pdf.Generator.Pdf toc = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section section = toc.Sections.Add();

Aspose.Pdf.Generator.Text text = new Aspose.Pdf.Generator.Text(“Table of Contents”);
text.TextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center;
text.TextInfo.FontSize = 18;
text.TextInfo.IsTrueTypeFontBold = true;
section.Paragraphs.Add(text);

Aspose.Pdf.Generator.Table table = new Aspose.Pdf.Generator.Table();
table.ColumnWidths = @“400 50”;
table.ColumnAdjustment = Aspose.Pdf.Generator.ColumnAdjustmentType.Customized;
table.Rows.Add();
table.Rows[0].Cells.Add();
table.Rows[0].Cells.Add();
table.Rows[0].Cells[0].ColumnsSpan = 2;
table.Rows[0].Cells[0].DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Left;
table.Rows[0].Cells[1].DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Right;
section.Paragraphs.Add(table);

string lastHeader = string.Empty;

for (int i = 0; i < 80; i++)
{
Aspose.Pdf.Generator.Row row = table.Rows.Add();
row.Cells.Add("Row " + i);
}

string tocFilename = @“C:\James\SamplePDF.pdf”;
toc.Save(tocFilename);

Hi James,

Thank you for sharing the sample code.

I am able to reproduce your mentioned issue after an initial test. Your issue has been registered in our issue tracking system with issue id: PDFNEWNET-33578. You will be notified via this forum thread regarding any updates against your reported issue.

Sorry for the inconvenience,

Thank you. Are there any workarounds that I can use to get around this issue until a patch is received? As you can appreciate, this is a critical function that I rely on.

Hi James,


Thanks for contacting support.

I have further investigated this issue and have found that the code that you have shared has started causing issue since the release of version 6.8.0 and 6.9.0 because during my testing, I have observed that when tested with Aspose.Pdf for .NET 6.7.0, the PDF document is properly being generated. As it seems to be an issue introduced in recent release versions, so we hope to get it resolved shortly. Please be patient and spare us little time. Please be patient and spare us little time. We are really sorry for this inconvenience.

I had the same problem and I’ve solved the issue by switching back to version 6.7.0 (as mentioned in the previous post).

Hi Danial,

Sorry for this inconvenience.

I am very pleased to inform you that the issue is resolved by the development team and this issue will be a part of Aspose.Pdf for .NET v7.1 (to be released in July as per our monthly release plan) after following the complete testing and release cycle. Please be patient and we will notify you once the version is available for download.

Again, we are really sorry for your inconvenience.

Thanks & Regards,

The issues you have found earlier (filed as PDFNEWNET-33578) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.