Hi,
We have the problem that custom table of content (TOC) is destroyed by calling the UpdateFields() method.
If only using the standard TOC’s we don’t see the problem, but if customer adds a fourth level to the TOC thus creating a custom TOC then the problem appears, the TOC is destroyed.
Provided is test code that reproduces the problem (AsposeWordsTocTest.aspx) and an input file (test_input.docx) for the test case. test_input.docx contains two TOC’s, a standard TOC, and a modified TOC. The test code opens the test_input.docx file calls UpdateFields() method and saves the result to file test_output.docx. As you see the second TOC, the custom TOC, is destroyed. We have tested with different versions of Words including the latest (17.3.0.0).
We really hope You can solve this issue since it is difficult to find a good workaround.
Thanks, and kind regards
Sven Andersen
Hi Sven,
Thanks for your inquiry. I have tested the scenario with your shared document using Aspose.Words for .NET 17.3.0 and noticed the reported issue. However, we will appreciate it if you please share your sample code to add custom TOC, it will help us to investigate and address your issue exactly.
We are sorry for the inconvenience.
Best Regards,
Hi Tilal, many thanks for your response.
Our customer has been so kind to make an instruction for creating the custom TOC in MS Word.
I hope this will help You.
Thanks, and kind regards
Sven Andersen
Hi Sven,
Thanks for sharing the additional information. Please note the custom TOC of your DOCX file are created under some different language culture instead of English culture. The TOC field is separated by “;” instead of “,”. To update TOC under English culture you need to either replace “;” with “,” in TOC field or change your application CurrentCulture according to your culture. I have tried the scenario with French culture and it is working as expected.
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fr-FR");
Document doc = new Document(@"test_input.docx");
doc.UpdateFields();
doc.Save(@"TOC_out.docx");
Please feel free to contact us for any further assistance.
Best Regards,
Hi Tilal,
I can also reproduce this.
I will try to find a solution with customer, hopefully it will be as simple as a US-En global policy on separator list delimiter. Obviously it is not an Aspose issue, I can reproduce with MS Word as well, and it is a general issue, regional settings on different PC’s will cause co-working problems, not just here but also in other Office products like number decimal delimiter in Excel, etc.
Many thanks for your help, and fast/good response
Thanks and kind regards
Sven Andersen
Hi Sven,
Thanks for your understanding. Please keep using our API and feel free to contact us for any further query or concern, we will be happy to extend our support.
Best Regards,