I just downloaded Aspose Words 7 and I noticed the UpdateFields() method has been enhanced.
I’m wondering are there any plans to support Appendices and Tables Of Contents?
It would be useful for our customers, as we specialise in document translation software,
and post-translation, TOCs and indexes remain untranslated, so users have to right-click on TOCs and appendices and click “update field” within Word to update their contents with the new data inside the translated index entry and TOC entry fields. It would be a really nice feature
Thanks for your request. We are still working on Fields Calculation Engine, which will allow updating all fields. Updating TOC fields will be supported in a one of the next releases. Please see the following link to learn more
The issues you have found earlier (filed as 10380) have been fixed in this update.
I’ve just downloaded Aspose.Words 9.0 to try out the new UpdateFields() functionality. Is it possible to dynamically create a TOC without having to subsequently print to PDF or XPS?
Yes, it is possible to build a complete TOC without saving to PDF or XPS, but you need to call Document.UpdatePageLayout after calling Document.UpdateFields.
The way it works is as follows.
1. Document.UpdateFields calculates results of all fields in the document. For TOC fields, it just deletes the existing TOC contents and builds a new one. It builds toc entries from heading paragraphs, TC fields and outline paragraphs as per the TOC field switches. But at this stage the TOC field does not have actual page numbers. At this stage HYPERLINK and PAGEREF fields are inserted and Aspose.Words reserves some space for the page number.
2. Saving to PDF or XPS or printing requires building the layout model of the document and internally calls Document.UpdatePageLayout. If you do not want to save to PDF or XPS, just call Document.UpdatePageLayout directly. This method (in addition to building the layout model) updates results of all fields that are related to page numbering. This includes PAGE, PAGES, PAGEREF, SECTION, SECTIONS etc. This inserts correct page numbers into the TOC.