1

I have been able to successfully generate word document (.docx) using OpenXML SDK 2.5.

Can we directly update the page numbers in TOC of the generated document using OpenXML SDK I found few similar queries on Stack overflow.

[https://stackoverflow.com/questions/28348550/how-to-generate-table-of-contents-using-openxml-sdk-2-5]

[https://stackoverflow.com/questions/9762684/how-to-generate-table-of-contents-using-openxml-sdk-2-0/]

One of the ways is to have users click yes to update the Table of Contents on a modal dialog when they open the document the first time. Is there a way to avoid this modal dialog and user intervention but still update page numbers on opening the document the first time?

Thanks, Gagan

Gags
  • 827
  • 2
  • 13
  • 29

1 Answers1

1

Since the page numbers can be different depending on how the opening application renders the document, i don't think that there is a way to do that by means of the OpenXml-SDK.

You can update fields/tocs using a macro or automation: How to automatically update tables of contents

docsjoe
  • 61
  • 4
  • I don't want to use automation. And for using a macro I need to have a Macro enabled document with extension docm'. How do I do this in a docx file. – Gags Feb 08 '21 at 05:05
  • In this case, if you do not want to render the document yourself, i suppose using some third-party (i.e. Aspose) tool to get the rendering done. Maybe there will be a license fee. – docsjoe Feb 08 '21 at 10:29