How to insert many nodes in one Cell with DocumentBuilder?

In this code, I have problem:
I have NodeCollection paragraph. I want add them to one cell with documentbuilder.

documentBuilder.StartTable();
Cell cell = new Cell(doc1);
NodeCollection nodeParagragh; //some paragraph
foreach (Paragraph paragraph in nodeParagragh)
{
    cell.AppendChild(paragraph);
}
documentBuilder.InsertNode(cell);
documentBuilder.EndRow();
documentBuilder.EndTable();

I know, I can do that with cell.AppendChild and add cell to a table, but I just want to do it with Documentbuilder.
Please help me. Thank you!

@quanghieumylo I am afraid you cannot insert existing paragraphs using DocumentBuilder. In your case you should use AppendChild method. For example see the following code:

builder.StartTable();
Cell cell = builder.InsertCell();
foreach (Paragraph paragraph in nodeParagragh)
{
    cell.AppendChild(paragraph);
}
builder.EndRow();
builder.EndTable();
1 Like

Thank you so much!

1 Like