Add table of contents after first page

Home Forums Open-Xml-Sdk Add table of contents after first page

Tagged: , , ,

This topic contains 1 reply, has 2 voices, and was last updated by  Eric White 8 years, 6 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #3451

    Prashant
    Participant

    Hello,

    I am using OPENXML SDK to convert HTML to word document using HTMLtoDOCX.CreateFileFromHTML method in my C#.Net web application and it is working fine.

    Now my requirement is like, i want to add table of contents to the word document after cover page. I have tried below code to do that and it is adding table of contents to the word document.

    OpenXmlPowerTools.TocAdder.AddToc(wdoc, firstPara,@”TOC \o ‘1-3’ \h \z \u”, null, null);

    The above code works fine, but it is adding it to the first page, but for me, first page will always be cover page. So how can i add table of contents to second page using OPENXML?

    #3456

    Eric White
    Keymaster

    You need to find the paragraph in the document before which you want to add the TOC, and pass that paragraph to the AddToc method.

    The question for you is how will you find the first paragraph after your cover page?

    If your cover page has a page break at the end, then that is probably the easiest way to find it.

    What does the markup for your cover page look like? Do you have a page break at the end of it?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.