Append Join Merge Word Documents Containing Multiple TOC Fields (Table of Content) & Retain Page References using Java

I am attaching the code in which I am merging two documents. Both documents have respective TOC.

After documents are merged: if I go to the second TOC on page# 4 and click on the index element it points to the wrong element. How can I fix this?

I tried using doc.updateFields(); but this would merge all my TOCs into a single TOC. I want to keep the TOC separate.

Uploading the Code here along with the output : (86.0 KB)


We tested the scenario and have managed to reproduce the same problem on our end. For the sake of any correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-20084. We will further look into the details of this problem and will keep you updated on the status of the linked issue. We apologize for your inconvenience.