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

Free Support Forum - aspose.com

Position or Move Cursor to just after Heading Paragraph & Insert a Table Shape Field etc in Word Document using C# .NET

How can I specify where the table I would like to create be placed in a word document?
When I use
It just starts creating the table at the top of the page; however, I’d like to place the table under a heading in the middle of the page.


You can build logic on following code to get the desired output:

Document doc = new Document("C:\\Temp\\input.docx");

// Locate the Node or Paragraph you want to insert Table after
Paragraph targetPara = null;
foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
    if (para.ParagraphFormat.StyleIdentifier == StyleIdentifier.Heading1)
        targetPara = para;

// Move cursor to target Node or Paragraph
DocumentBuilder builder = new DocumentBuilder(doc);

// create Table
CellFormat cellFormat = builder.CellFormat;
cellFormat.Width = 250;
cellFormat.LeftPadding = 30;
cellFormat.RightPadding = 30;
cellFormat.TopPadding = 30;
cellFormat.BottomPadding = 30;
builder.Writeln("I'm a wonderful formatted cell.");


In case the problem still remains, please ZIP and attach the following resources here for testing:

  • Your simplified input Word document
  • Aspose.Words for .NET 20.8 generated output DOCX file showing the undesired behavior (if any)
  • Your expected DOCX file showing the desired output. You can create this document by using MS Word.

As soon as you get these pieces of information ready, we will start further investigation into your scenario and provide you code to achieve the same by using Aspose.Words for .NET.