Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Jul 27, 2021 3:06 pm

Numbered headings are not mapped correctly in the table of contents. The list should start at 1, but continues with the next number.
1. One
This is text under one.

2. Two
This is text under two.

3. Three

displays in table of contents as:
Contents
4. One 1
5. Two 1
6. Three 1

Sample template (before running UpdateTableOfContents()) is attached.

Version 9.7.3

mike.woolsoncroft
 
Posts: 14
Joined: Tue May 05, 2020 2:11 pm

Wed Jul 28, 2021 3:44 am

Hello,

Thanks for your inquiry.
I did an initial test but did not reproduce your issue. To help us reproduce your issue and help you solve it, please tell us your project target framework (e.g. .NET Framework 4.5) and your OS information (e.g. Windows7, 64bit). Thanks in advance.

Sincerely,
Brian
E-icblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed Jul 28, 2021 1:23 pm

Hello Brian,

I am using Windows 10 Enterprise 19043.1110
.Net Core 3.1
Spire.doc 9.7.3

The template is loaded via: doc.LoadFromStream(template, fmt);
After doc.UpdateTableOfContents()
I see 4,5,6 in the table of contents:
4. One
5. Two
6. Three

Expected to see the same numeric values as in the headers:
1. One
2. Two
3. Three

Thank you!

mike.woolsoncroft
 
Posts: 14
Joined: Tue May 05, 2020 2:11 pm

Thu Jul 29, 2021 3:44 am

Hello,

Thanks for providing more information.
I tested your case in a similar environment to yours, but I did not reproduce your issue. Here I upload my project and you can run it directly. Please let us know your testing results.

If this issue only occurs in your project, please provide your runnable project to help us investigate further. Thanks in advance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Thu Jul 29, 2021 2:09 pm

That project was very helpful and worked correctly for me too.

I did some more investigation and found there is one more function call being done in my project (it was nested in another function and I did not notice it initially).
Adding a call to doc.GetText() in the sample project will reproduce the issue in your test project:

...
doc.LoadFromStream(File.OpenRead("NumberedHeading.docx"),FileFormat.Docx);
doc.GetText();
doc.UpdateTableOfContents();
...

Thank you!

mike.woolsoncroft
 
Posts: 14
Joined: Tue May 05, 2020 2:11 pm

Fri Jul 30, 2021 1:39 am

Hello,

Thanks for your feedback.
I tested adding the line "doc.GetText();" before "doc.UpdateTableOfContents();", and did reproduce your issue. I have logged it in our bug tracking system with the ticket SPIREDOC-6449. If there is any update, we will let you know. Apologize for the inconvenience caused.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.Doc