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

Free Support Forum - aspose.com

How to insert a line of data before table after section break

Hi team,

I’m facing an issue to insert a line of data before table after section break. When there is no section break and a table is present I’m able to insert data.
Could you please help me out on this please?

The actual context is table title will be present inside the table where i need to move table title out of table and insert it above table.

@kkumaranil485

Please move the cursor to the previous node of table and insert the desired text as shown below. Please read the following article for more detail.


21.8.docx (9.4 KB)
input.docx (12.0 KB)
Document doc = new Document(MyDir + "input.docx");
DocumentBuilder builder = new DocumentBuilder(doc); 
                
Table table = (Table)doc.GetChild(NodeType.Table, 0, true);
if (table.PreviousSibling == null)
{ 
    table.ParentNode.InsertBefore(new Paragraph(doc), table);
}
builder.MoveTo(table.PreviousSibling);

builder.Write("Some text before table");
doc.Save(MyDir + "21.8.docx");