Free Support Forum -

Help creating a Table of Contents with links when merging PDFs


I'm hoping someone can help me find a way to create a table of contents type of page. Basically I have about 5 pdfs that I need to merge into 1 pdf and also include a Table of contents. On the table of context there will be a link to each page with some type of text explaining each page.

I was hoping I could Aspose.Words to create the Table of Contents page for layout purposes and then modify the XML file in code to add the links. So in the xml file below I have added LinkType and LinkPageNumber. When I create the PDF and then merge all 6 pdfs together using pdf.kit's concatenate, the links to do not take me the page number listed. I then tried to use the ExtractLink() method in pdf.kit to see if the links looked ok, but receive an "Invalid Characters" type of message when getting the link pointing to page two.

<?xml version="1.0" encoding="UTF-8"?>



Looks like I can use the pdf.kit's CreateLocalLink, but the layout of the Table of Contents could change and I'm not sure how I'd determine where to place the rectangle object at runtime.

Here's the steps I was hoping to take:

1. Open xml file, replace the text {link.1} and {link.2} with text describing the page the link points to.

2. Save xml and generate Table of Contents Page from the updated XML file.

3. Merge the 6 pdfs using PDF.Kit.

Any suggestions/solutions would be greatly appreciated.

BTW: I also looked into setting the destpagenumbers to 1 to bypass the "Invalid Characters" issue. But according to this thread: I cannot modify the links :(



Hi Chris,

Thank you for considering Aspose.

You requirement is not supported. If you create the TOC PDF and merge the other PDF files into it, the links inside the TOC will not work. We can’t support this feature in short time.
Currently the only available solution is merging PDF documents first and then adding links in existing PDF. We will try to make this easier in the future version.