Table of contents text color gets changed

In the attached document the TOC on page 2 gets converted to white text from black.

RS 2023-04944-63 Västra Götalandsregionens investeringsplan 2025-2034 3820199_13_0.docx (347.3 KB)

Before:

After:

Output:
output.pdf (292.9 KB)

Sample code:

using Aspose.Words;

Aspose.Words.License license;
license = new Aspose.Words.License();
license.SetLicense("Aspose.Total.NET.lic"); 

string dataDir = "c:\\temp\\";

Document doc = new Document(dataDir + "test.docx");
doc.UpdateFields();
doc.Save(dataDir + "output.pdf", SaveFormat.Pdf);

@andersalvsaker Could you please attach your output document here for our reference and provide simple code that will allow us to reproduce the problem? We will check the issue and provide you more information.

I have now provided sample code from a simple console application I made and the output pdf. Please note that UpdateFields is the issue. If I remove this, the output is ok.

@andersalvsaker Thank you for additional information. It looks like Aspose.Words behavior is correct. If you update TOC in MS Word you will see exactly the same.

Can you ellaborate how you update TOC in MS word to reproduce this?

Edit: do you mean right clicking and then selecting update field?

@andersalvsaker

Yes.

I was able to reproduce it now in MSword. Thank you for your assistance :slightly_smiling_face:

1 Like