简体   繁体   中英

How to generate Table Of Contents using OpenXML SDK 2.5?

I've read and understand this and this Stackoverflow question but there all about OpenXML SDK 2.0. In OpenXML SDK 2.0 there is no real way to update the Table of Content (ToC). There are a few workarounds like marking the document dirty which will ask the user to update the ToC on opening the document, update the ToC using office automation or update the ToC using a word macro.

Unfortunately, none of this solutions fits for my problem.

Is there an more convenient way to update the ToC using Open XML SDK 2.5 ?

The problem is not related to openxml and its versions. In openxml , as document standard, you only define the need of pagination (by a formula place holder) but the pagination only occurs at RENDERING phase (which is not related to openxml). As you have already seen whenever opening a word document, the pagination is running live at bottom of the word editor. So the only way is simulating it and it can only be happened by office automation ( or a similar tool) or making it dirty. Note that in PDF generation the problem is a little different. The pages are specified at definition level not rendering level.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM