We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to clone and insert table and split them by page break using C#

hi there…


This code is made by copying table of aspose.word.
I need to insert a pagebreak between the tables, please tell me how to do it.

g_docWord = new Document(Server.MapPath("~/template/") + “abc.doc”);
g_dbBuilder = new DocumentBuilder(g_docWord);

Table table = (Aspose.Words.Tables.Table)g_docWord.GetChild(NodeType.Table, 0, true);
Aspose.Words.Tables.Table tableClone = (Table)table.Clone(true);
table.ParentNode.InsertAfter(tableClone, table);
table.ParentNode.InsertAfter(new Paragraph(g_docWord), table);

@ClaireChang

Thanks for your inquiry. Please use the following code example to achieve your requirements. Hope this helps you. Please let us know if you have any more queries.

Document doc = new Document(MyDir + "in.docx");

Table table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);

Aspose.Words.Tables.Table tableClone = (Table)table.Clone(true);

table.ParentNode.InsertAfter(tableClone, table);

Paragraph para = new Paragraph(doc);

table.ParentNode.InsertAfter(para, table);

para.AppendChild(new Run(doc, ControlChar.PageBreak));

doc.Save(MyDir + "Out.docx");