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

Free Support Forum - aspose.com

Merge and create table of content

hi there,

i would like to know:

1- If it is possible to merge word document and add the table of content at
a same time.

2- Is there a code sample that I can use in C#?

What I trying to do is to get multiple word (.doc or .docx)
documents and merge them and at a same time I want to be able to create “table
of content” on top of the page and point them to the file that I receive

thanks, Maziar

Hi Maziar,
Thanks for your inquiry.

  1. Sure, you can insert one document into another document in many ways. I would suggest you please read the following articles:

https://docs.aspose.com/words/java/insert-and-append-documents/
https://docs.aspose.com/words/net/insert-and-append-documents/

  1. Once you have joined all documents into a single document and created a final document, you can use the following code snippet to insert a Table of Content field at the start of your final document:
// Create a document builder to insert content with into the document.
DocumentBuilder builder = new DocumentBuilder(doc);
// Move the cursor to the document start
builder.MoveToDocumentStart();
// Insert a table of contents at the beginning of the document.
builder.InsertTableOfContents("\o "1-3" \h \z \u");
// Start the actual document content on the second page.
builder.InsertBreak(BreakType.PageBreak);

I hope, this helps.
Best regards,