Hello Aspose,
I’m using Aspose,pdf 24.9.
I get following crash when rendering:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at Aspose.Pdf.Rows.get_Item(Int32 index)
at Aspose.Pdf.Cell.#=zh4y3BSaCRFY6(Double #=zS62qbNc=, Double #=zrR_OI6o=, Row #=zqy$s42E=, Table #=zW0PL5QY=, Int32 #=z__DH$ow=, Double #=zHfIh1QKHFMzC)
at Aspose.Pdf.Row.#=zmjhMReo=(Table #=zW0PL5QY=, Double& #=zrR_OI6o=, Double& #=zS62qbNc=, Boolean #=z8i_qvGuovGqM, Double #=z9zPqWXzRjOLb, Double #=z3z7AbNU=, Page #=z3X5IwPM=, Int32& #=zVYwxtTo5OVYm)
at Aspose.Pdf.Table.#=zf0GJFIiu30g8(Double #=zS62qbNc=, Double #=zrR_OI6o=, Boolean #=z8i_qvGuovGqM, Double #=zVgtq0Eadp0p_, Double #=z3z7AbNU=, Page #=z3X5IwPM=)
at Aspose.Pdf.Table.#=zmjhMReo=(Double& #=zS62qbNc=, Double& #=zrR_OI6o=, Boolean #=z8i_qvGuovGqM, Double #=zVgtq0Eadp0p_, Double #=z3z7AbNU=, Page #=z3X5IwPM=, Boolean #=zASdnIiiJhRWE, List1 #=zzSaZ$l4=) at #=zrWR_2hKODD1gTtdvBsPn$ME=.#=zmjhMReo=() at Aspose.Pdf.Page.#=zsUKWRJmLTGib(Page #=z3X5IwPM=, List
1 #=zzSaZ$l4=, Double #=zYOiNGjs=, Double #=zRafGWU4=)
at Aspose.Pdf.Page.#=zT9V2VYE=(Page #=z3X5IwPM=)
at Aspose.Pdf.Page.#=z_ePVv1AYkTHKzDc1qg==()
at Aspose.Pdf.Document.ProcessParagraphs()
at Aspose.Pdf.Document.#=zgFborrY2q_Wl(Stream #=zz1YnIaA=, SaveOptions #=z0xv9rOYdoNjq)
at Aspose.Pdf.Document.#=zHcaOqkArB0by(Stream #=zz1YnIaA=, SaveOptions #=z0xv9rOYdoNjq)
at Aspose.Pdf.Document.#=zuAeKV0UFRV4m(String #=z5fbv6sIQpZIm)
at Aspose.Pdf.Document.Save(String outputFileName)
at ConsoleAppGerd.Program.Main() in B:\Service\SYSA_ServiceReporting\Test\ConsoleApp1\Program.cs:line 47
I can reproduce with this code:
private static string TableCrash(Page page)
{
var table = new Table()
{
ColumnWidths = null,
Alignment = HorizontalAlignment.Left,
ColumnAdjustment = ColumnAdjustment.AutoFitToWindow,
DefaultColumnWidth = "100",
RepeatingColumnsCount = 0,
RepeatingRowsCount = 1,
Broken = TableBroken.None,
IsBroken = true,
DefaultCellBorder = null,
DefaultCellPadding = null,
DefaultCellTextState = new TextState("Arial", false, false)
{
HorizontalAlignment = HorizontalAlignment.Left,
FontSize = 9F,
LineSpacing = 0,
BackgroundColor = Color.AliceBlue,
ForegroundColor = Color.White
},
Margin = new MarginInfo() { Left = 0, Top = 20, Right = 0, Bottom = 20 },
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Left,
IsFirstParagraphInColumn = false,
IsInLineParagraph = false,
IsInNewPage = false,
IsKeptWithNext = false,
BreakText = new TextFragment("(continued)")
};
var r1 = new Row()
{
BackgroundColor = Color.Black,
FixedRowHeight = 0,
MinRowHeight = 0,
IsInNewPage = false,
IsRowBroken = false,
VerticalAlignment = VerticalAlignment.None,
DefaultCellPadding = null,
// DefaultCellTextState = Aspose - TextInfo: Helvetica, File: Helvetica, Size: 0, Bold: False, Italic: False, LineSpace: 0, Color: ff000000, Alignment: Left: BgColor:
DefaultCellBorder = null,
Border = null
};
var r2 = new Row()
{
BackgroundColor = Color.Black,
FixedRowHeight = 0,
MinRowHeight = 0,
IsInNewPage = false,
IsRowBroken = false,
VerticalAlignment = VerticalAlignment.None,
DefaultCellPadding = null,
// DefaultCellTextState = Aspose - TextInfo: Helvetica, File: Helvetica, Size: 0, Bold: False, Italic: False, LineSpace: 0, Color: ff000000, Alignment: Left: BgColor:
DefaultCellBorder = null,
Border = null
};
var r3 = new Row()
{
BackgroundColor = Color.Black,
FixedRowHeight = 0,
MinRowHeight = 0,
IsInNewPage = false,
IsRowBroken = false,
VerticalAlignment = VerticalAlignment.None,
DefaultCellPadding = null,
// DefaultCellTextState = Aspose - TextInfo: Helvetica, File: Helvetica, Size: 0, Bold: False, Italic: False, LineSpace: 0, Color: ff000000, Alignment: Left: BgColor:
DefaultCellBorder = null,
Border = null
};
table.Rows.Add(r1);
table.Rows.Add(r2);
table.Rows.Add(r3);
var c11 = new Cell()
{
//Width = 0,
Alignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Center,
IsNoBorder = false,
IsOverrideByFragment = false,
IsWordWrapped = true,
ColSpan = 2,
RowSpan = 1,
Margin = new MarginInfo() { Left = 7, Top = 10, Right = 7, Bottom = 10 },
Border = new BorderInfo(BorderSide.All, 1.0F, Color.White),
DefaultCellTextState = new TextState("Arial", true, false)
{
HorizontalAlignment = HorizontalAlignment.Left,
FontSize = 9F,
LineSpacing = 1,
BackgroundColor = Color.AliceBlue,
ForegroundColor = Color.White
},
BackgroundColor = Color.AliceBlue,
Paragraphs = {new TextFragment("Hello")}
};
r1.Cells.Add(c11);
var c21 = new Cell()
{
//Width = 0,
Alignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Center,
IsNoBorder = false,
IsOverrideByFragment = false,
IsWordWrapped = true,
ColSpan = 1,
RowSpan = 1,
Margin = new MarginInfo() { Left = 7, Top = 10, Right = 7, Bottom = 10 },
Border = new BorderInfo(BorderSide.All, 0.5F, Color.White),
DefaultCellTextState = new TextState("Helvetica", false, false)
{
HorizontalAlignment = HorizontalAlignment.Left,
FontSize = 9F,
LineSpacing = 1,
BackgroundColor = Color.LightBlue,
ForegroundColor = Color.White
},
BackgroundColor = Color.LightBlue,
};
var c22 = c21.Clone() as Cell;
var c31 = c21.Clone() as Cell;
var c32 = c21.Clone() as Cell;
c21.Paragraphs.Add(new TextFragment("1-1"));
c22.Paragraphs.Add(new TextFragment("1-2"));
c31.Paragraphs.Add(new TextFragment("2-1"));
c32.Paragraphs.Add(new TextFragment("2-2"));
r2.Cells.Add(c21);
r2.Cells.Add(c22);
r3.Cells.Add(c31);
r3.Cells.Add(c32);
page.Paragraphs.Add(table);
return Path.Combine(myDataDir, "TableCrash.pdf");
}
public static void Main()
{
Document doc = new Document();
Page page = doc.Pages.Add();
var file = TableCrash(page);
if (File.Exists(file)) { File.Delete(file); }
doc.Save(file);
Process.Start(file);
}
If I comment this line
BreakText = new TextFragment("(continued)")
the crash is not appearing and the table looks fine.
Is there a workaround, because the BreakText is urgently required.
Regards
Gerd