0

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?

User5590
  • 1,383
  • 6
  • 26
  • 61

1 Answers1

1

To accomplish your task, you must know the page number of the Element that your are going to insert before or after.

It is not possible to get page numbers for a word document using OpanXml Sdk as this is handled by the client (like MS Word). However you can get some ideas from "this answer"

Community
  • 1
  • 1
Kunalan Krish
  • 232
  • 1
  • 14