We are currently using the updateFields option in WordProcessingLoadOptions to update the Table of Contents in our documents. However, we have observed that enabling this flag increases the processing time by approximately 30–40%.
Could you please clarify why this additional overhead occurs? Also, is there any recommended approach or possible optimization we can do on our side to reduce the impact on performance? Or can this be fixed from GroupDocs side to reduce the performance impact while still updating the TOC?
Looking forward to your guidance.
Thank you.
@ravi1994
Thanks for reaching out!
Could you share the document you’re converting (or a sample that shows the slowdown)? The overhead depends a lot on the document’s content, so your actual file will let us check it properly.
That said, the extra time is expected. With UpdateFields enabled, the library recalculates all fields in the document and resolves the page layout — TOC entries, page numbers and cross-references can only be computed once the whole document is paginated. So the cost naturally scales with document size and TOC complexity.
Once we have your sample, we’ll take a closer look to see if anything can be optimized.
Hi @nikola.yankov
We have created a sample project to reproduce the issue and executed the conversion in a loop 10 times to measure the average conversion time.
Please run the commands below to compare the performance with updateFields enabled and disabled.
Before running the commands, ensure that:
- Docker is running.
- A valid GroupDocs license file named
GroupDocs.Total.Java.lic is placed under the license folder.
Commands:
mvn clean install && docker build --platform linux/amd64 -t groupdocs-sample-amd64-nots . && docker run -m 9g --cpus=2 -p 8081:8080 groupdocs-sample-amd64-nots
With updateFields enabled:
curl --location --request POST 'http://localhost:8081/api/conversion/toc?orgId=Org2&fileName=TocPerfTest'
With updateFields disabled:
curl --location --request POST 'http://localhost:8081/api/conversion/notoc?orgId=Org2&fileName=TocPerfTest'
Please check the log output at the end. You should observe an additional 30–40% increase in conversion time when updateFields is enabled.
We are also attaching the document and the sample project ZIP file required to reproduce the issue.
TocPerfIssue.zip (666.1 KB)
TocPerfTest.docx (626.6 KB)