Updating page numbers of ToC in Aspose is 15x+ slower than updating in MS Word manually


I’m using the following code to update the page number of the table of content without updating the entire ToC, which is the equivalent operation of ‘Update Page numbers only’ in Word:

image.png (11.5 KB)

var convertedDocument = new Document(@"\test.docx");
            foreach (Field field in convertedDocument.Range.Fields)
                if (field.Type != FieldType.FieldTOC)

                var toc = (FieldToc)field;
                // Takes less than 2 mins in Word by right clicking the ToC -> update page numbers only
                // Takes nearly 30 minutes in Aspose
                toc.IsLocked = true;

            // As the TOC field is locked, the following should not update it

            var option = new PdfSaveOptions();
            option.UpdateFields = false;
            convertedDocument.Save(@"\out.pdf", option);

This code was based on the suggestion in Update Page Numbers Only of Table of Contents TOC Field or Update Entire Table TOC Field in Word Document using C# .NET - #6 by awais.hafeez

I found that in the document attached, it took only less than 2 minutes to update page number only in Word, but with Aspose, it took nearly 30 minutes with a lot of memory/CPU consumption, literally making the function not usable.

test.zip (2.1 MB)

Could you please help us check the issue?



We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-21231 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.