Hello. I am using Aspose.Words .Net and have an issue with updating styles in a TOC that I am trying to understand.
I have a DOCX (see Original.docx, attached) with a table of contents. The numbering of the TOC has a regular style. The numbered list used for the section headings in the rest of the document has a bold style. When I update the fields in Word using the Update Field option, the TOC updates and retains the regular style for the numbers (see UpdatedFile-Word.docx), ignoring the bold style of the numbered list. I believe this is the correct behaviour. When Aspose updates the fields, the numbering in the TOC is changed to bold (see UpdatedFile-Aspose.docx).
I have tested with Apose.Words 24.10.0 (demo version) and 23.2.0.0. The behaviour is present in both. I am updating the fields in the document with the following code:
var document = new Document(originalFile);
document.UpdateFields();
document.Save(updatedFile);
I’d like to know why there is a difference in behaviour. I believe that UpdateFields should result in the same styles being applied as happens with Word’s Update Fields option. Is that the case or can anyone suggest why it would be different?
Example files:
- Original.docx (57.5 KB)
- UpdatedFile-Aspose.docx (66.1 KB)
- UpdatedFile-Word.docx (57.6 KB)