Hi,
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)
continue;
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.UpdatePageNumbers();
toc.IsLocked = true;
}
// As the TOC field is locked, the following should not update it
convertedDocument.UpdateFields();
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?
Thanks,