Free Support Forum - aspose.com

How to insert Table of contents in Second page? Aspose.Words - .Net

I have to insert the Table of Contents in second page of Word Document .docx, as the first page have the image and Title,

the following code keeps the Table of Contents over the image in first page.

DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a table of contents at the beginning of the document.
builder.InsertTableOfContents("\\o \"1-3\" \\h \\z \\u");

Also I just have to show the "Heading 1" only and not heading2, heading3... in the table of contents, should i use ("\\o \"1-1\" \\h \\z \\u"); ?

Thanks in advance

Hi

Thanks for your request.

1. You can insert a bookmark where you need to insert TOC. Then you will be able to move DocumentBuilder cursor where you need to insert the TOC and insert it there.

Also you can attach your template here, we will take a look and try to give some advice.

2. Yes, you should use "\o "1-1" \h \z \u"

Best regards,

Hi Alexey,Appreciate the quick reply and help. I am able to solve the issue using the following code. This solves my purpose.

DocumentBuilder

builder = new DocumentBuilder(doc);

builder.MoveToDocumentEnd();

builder.InsertTableOfContents("\\o \"1-1\" \\h \\z \\u");

Hi

It is perfect that you managed to resolve the problem. Please let us know if you need more assistance, we will be glad to help you.

Best regards,