Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

PDF.ColumnAdjustment.AutoFitToContent throws error

$
0
0
AutoFitToContent will throw an error when the table it is processing doesn't have the same number of cells in the row.  However, when you are just adding the table without AutoFitToContent, it will parse normally.

The specific error is "An unhandled exception of type 'System.IndexOutOfRangeException' occurred in Aspose.Pdf.dll"

Dim file As New MemoryStream

Dim myDoc As New Aspose.Pdf.Document

Dim myPage2 As Aspose.Pdf.Page = myDoc.Pages.Add()

Dim myTable As New Aspose.Pdf.Table

Dim firstRow As Aspose.Pdf.Row = myTable.Rows.Add()
firstRow.Cells.Add("1 1")
'firstRow.Cells.Add("1 2") '<-- Adding this in will fix the issue.

Dim secondRow As Aspose.Pdf.Row = myTable.Rows.Add()
secondRow.Cells.Add("2 1")
secondRow.Cells.Add("2 2")

'myTable.ColumnAdjustment = Aspose.Pdf.ColumnAdjustment.AutoFitToContent  ' <-- Offending line

myPage2.Paragraphs.Add(myTable)

myDoc.Pages.Add(myPage2)

myDoc.Save(file)

Viewing all articles
Browse latest Browse all 3131

Trending Articles