Table with nested table can't span page?

What am I doing wrong?

I have a table (main) with rows with one cell in each row. Inside of each cell is a table (nested) with one row with one cell. When the main table gets long enough to span pages I get an error, but when it is short (stays on one page) I get no error.

The error is “System.ArgumentException: Invalid orgin paragraph in Insert method”.

Setting the main table’s IsFirstParagraph = true does not help.

Sample Code:

private void Page_Load(object sender, System.EventArgs e)
Pdf pdf = Test();
pdf.Save(Response);
}

//For case i <= 46 its okay, but i > 46 I get error.
public Pdf Test() {
Pdf pdf = new Pdf();

Section section1 = new Section(pdf);
pdf.Sections.Add(section1);

//Create main table
Table table = new Table();
section1.Paragraphs.Add(table);

for( int i = 1; i <= 46; i++) {
AddRow(pdf, table, i.ToString());
}
return pdf;
}

private void AddRow(Pdf pdf, Table oTable, string s1) {

//Add new cell to original table
Row oRow = new Row(oTable);
oTable.Rows.Add(oRow);
Cell oCell = new Cell(oRow);
oRow.Cells.Add(oCell);
//Embed new table in new cell
Table table = new Aspose.Pdf.Table();
oCell.Paragraphs.Add(table);

Row row1 = new Row(table);
table.Rows.Add(row1);

Cell cell1 = new Cell(table);
row1.Cells.Add(cell1);
Text text1Cell1 = new Text();
cell1.Paragraphs = new Paragraphs();
cell1.Paragraphs.Add(text1Cell1);
Segment seg1Text1Cell1 = new Segment(text1Cell1);
text1Cell1.Segments.Add(seg1Text1Cell1);
seg1Text1Cell1.Content = s1;
}


Stack Trace:
ArgumentException: Invalid orgin paragraph in Insert method]
Aspose.Pdf.Paragraphs.InsertPara(Paragraph paragraphToInsertAfter, Paragraph newParagraph) +149
Aspose.Pdf.Xml.h7.ProcessSingleSegment(Pdf doc, Section currentPart, Table table, Row row, Cell cell, Text text, String content, AssignInfo assignInfo, Z7 useType) +2995
Aspose.Pdf.Xml.n7.ProcessText(Pdf doc, Section currentPart, Table table, Row row, Cell cell, Text text, AssignInfo assignInfo, Z7 useType, Boolean isFirst) +1242
Aspose.Pdf.Xml.D7.ProcessCell(Pdf doc, Section currentPart, Table table, Row row, Cell cell, AssignInfo assignInfo) +770
Aspose.Pdf.Xml.c7.ProcessRow(Pdf doc, Section currentPart, Table table, Row row, AssignInfo assignInfo) +533
Aspose.Pdf.Xml.m7.ProcessTable(Pdf doc, Section currentPart, Table table, AssignInfo assignInfo, Boolean isFirst) +627
Aspose.Pdf.Xml.D7.ProcessCell(Pdf doc, Section currentPart, Table table, Row row, Cell cell, AssignInfo assignInfo) +873
Aspose.Pdf.Xml.c7.ProcessRow(Pdf doc, Section currentPart, Table table, Row row, AssignInfo assignInfo) +533
Aspose.Pdf.Xml.m7.ProcessTable(Pdf doc, Section currentPart, Table table, AssignInfo assignInfo, Boolean isFirst) +627
Aspose.Pdf.Xml.e7.ProcessSection(Pdf doc, Section section, AssignInfo assignInfo) +886
Aspose.Pdf.Xml.I7.AssignPages(Pdf doc) +308
Aspose.Pdf.Xml.K7.GenerateDocument(G6 gen, Pdf doc) +26
Aspose.Pdf.Pdf.Save(HttpResponse response) +45
CORE.Reports.XML.XMLPdfReports.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\core\reports\xml\xmlpdfreports.aspx.cs:44
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731

Hi,

Are you using the latest hot fix?

Yes. Version 1.3.11.0 dated Aug 10, 2003 3:10pm.

Dear csuire,

Thanks for your consideration.

I am sorry for the bad example code of nested table and I will update it soon.

To use nested table in api, you should:

1) Use the Table(Section) constructor for the main table but not Table() constructor;

2) Use the Table(Cell) constructor for the nested table;

3) Use Cell(Row) constructor for cell instead of Cell(Table);

Here is the changed code:

public void DoTest()
{
Pdf pdf = Test();
pdf.Save(“d:/temp/test.pdf”);

}

//For case i <= 46 its okay, but i > 46 I get error.
public Pdf Test()
{
Pdf pdf = new Pdf();

Section section1 = new Section(pdf);
pdf.Sections.Add(section1);

//Create main table
// Table table = new Table();
Table table = new Table(section1); //changed by tommy
section1.Paragraphs.Add(table);

for( int i = 1; i <= 47; i++)
{
AddRow(pdf, table, i.ToString());
}
return pdf;
}


private void AddRow(Pdf pdf, Table oTable, string s1)
{

//Add new cell to original table
Row oRow = new Row(oTable);
oTable.Rows.Add(oRow);
Cell oCell = new Cell(oRow);
oCell.FitWidth = 120; //added by tommy
oRow.Cells.Add(oCell);
//Embed new table in new cell
// Table table = new Aspose.Pdf.Table();
Table table = new Aspose.Pdf.Table(oCell); //added by tommy
oCell.Paragraphs.Add(table);

Row row1 = new Row(table);
table.Rows.Add(row1);

// Cell cell1 = new Cell(table);
Cell cell1 = new Cell(row1);
cell1.FitWidth = 100; //added by tommy
row1.Cells.Add(cell1);
Text text1Cell1 = new Text();
cell1.Paragraphs = new Paragraphs();
cell1.Paragraphs.Add(text1Cell1);
Segment seg1Text1Cell1 = new Segment(text1Cell1);
text1Cell1.Segments.Add(seg1Text1Cell1);
seg1Text1Cell1.Content = s1;
}