We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

updateFields in .docx update table of contents to blank


We are using Aspose Word v14.7.0 with JDK 1.6 to concatenate multiple DOC and DOCX together. At the end of the process we are calling the updateFields() method just before saving the file.

When the source file is a DOC everything works, but when it is a DOCX and the table of content has been customized to modify the levels of the styles in the table of contents, at the end the table of content is blank, but it shouldn’t because after that if we re-update it manually it update correctly.

Here is a minimal test to re-produce the problem:
- Java:

import com.aspose.words.Document;
import com.aspose.words.SaveFormat;
import java.lang.Exception;

class Main {
    public static void main (String [] args) {
        try {
            Document doc = new Document("C:\\temp\\test.docx");
            doc.save("C:\\temp\\test_out.docx", SaveFormat.DOCX);
        } catch (Exception ex) {

Docx in attachement. The table of content is parametrized to show the style “Title” at the level 1, the style “Heading 1” at the level 2, the style “Heading 2” at the level 3.

We have tested with custom styles, it works correctly, but we need this to work with default styles too.


Hi Florian,

Thanks for your inquiry. I have tested the scenario using latest version of Aspose.Words for Java 14.11.0 and have not found the shared issue. Please use Aspose.Words for Java 14.11.0. I have attached the output document with this post for your kind reference.

The TOC field in your document uses style name in French language. If you are updating fields under different culture, please set Locale as shown below. Hope this helps you.

Locale.setDefault(new Locale("fr", "FR"));
Document doc = new Document(MyDir + "test.docx");
doc.save(MyDir + "Out.docx");