Table of contents. Two documents in one

I need to insert two documents in one and make a table of contents, which will be contains lnks to each of imported documents. How can I do it?

Hello
Thanks for your request. Please see the following link to learn how to insert one document into another:
https://docs.aspose.com/words/java/insert-and-append-documents/
If you just need to append the specified document to the end of current document, you can try using appendDocument method:
https://reference.aspose.com/words/java/com.aspose.words/document/#appendDocument-com.aspose.words.Document-int
You can use insertTableOfContents method to create TOC from scratch:
https://reference.aspose.com/words/java/com.aspose.words/documentbuilder/#insertTableOfContents-java.lang.String
Please let me know if you need more assistance, I will be glad to help you.
Best regards,