We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

HyperLink style is missing for the PageNumber text in the generated TOC (Table of Contents) field

We are currently evaluating Aspose Words Java 17.01 version and hit into this issue where HyperLink style is missing for the PageNumber text in the generated TOC (Table of Contents) field.

Steps to reproduce this issue:

#1) Take the attached “TOC_template.docx” document…

#2) Run the below specified program on this document using the previous Aspose Words Java version 15.11 and using the latest Aspose Words Java version 15.11…
I have attached them “TOC_generated_by_15.11.0.0.docx” and “TOC_generated_by_17.1.0.0.docx” for your reference…

#3) Compare the TOC (Table of Contents) field generated by the previous version 15.11 with that of latest version 17.01…
You will notice that “Hyperlink” style is missing for PageNumber text in the TOC field and also missing for the run node text inside Field Begin node…

Compare the “document.xml” in the generated documents…

You can check the attached pics:

Test Code:

public static void main(String[] args) throws Exception {
License license = new License();
Document doc = new Document(“TOC_template.docx”);
// Update TOC (Table of Contents) field.
Field tableOfContentsField = doc.getRange().getFields().get(0);
// Modify Hyperlink style font name.
doc.getStyles().get(“Hyperlink”).getFont().setName(“Bradley Hand ITC”);
// Save the modified document.
doc.save(“TOC_generated_by_” + BuildVersionInfo.getVersion() + “.docx”);

Can you please look into this… can you please provide if any workaround for this till it gets fixed?


Hi Satya,

Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-14774. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi Satya,

Thanks for your patience. It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-14774) as 'Not a Bug'.

Please note that Aspose.Words mimics the same behavior as MS Word does. MS Word does not apply HYPERLINK style to PAGEREF field in the TOC field result. If you update TOC field and change the font name of "Hyperlink" style using MS Word, you will get the same output. The older version 15.11.0 of Aspose.Words does not mimic MS Word behavior.

Please let us know if you have any more queries.