Free Support Forum -

How can I get the book mark in a concatenated pdf

Hi ,

I have concatenated 5 pdf files and generated a combined PDF. Now I need to display a bookmark for individual pdfs in the tray of the combined pdf. How can I do this ?

Code Sample :

//create input and output file streams

FileInputStream inStream1 = new FileInputStream("C:\\AsposeTest\\aug\\1.pdf");

FileInputStream inStream2 = new FileInputStream("C:\\AsposeTest\\aug\\2.pdf");

FileInputStream inStream3 = new FileInputStream("C:\\AsposeTest\\aug\\3.pdf");

FileInputStream inStream4 = new FileInputStream("C:\\AsposeTest\\aug\\4.pdf");

FileInputStream inStream5 = new FileInputStream("C:\\AsposeTest\\aug\\5.pdf");

FileOutputStream outStream = new FileOutputStream("C:\\AsposeTest\\aug\\FINAL.pdf");

//create array of input streams

InputStream[] inStreams = new InputStream[] {

inStream1, inStream2, inStream3, inStream4, inStream5};

//concatenate the input files from array of input streams

pdfEditor.concatenate(inStreams, outStream);


I am able to get the FINAL pdf . But I need a link for each files in the book mark tray of FINAL pdf, so that when i click on one link it will take me to respective file.

I am using Aspose 2.9.0

Hi Sriman,

When you concatenate PDF files, it is not feasible to create the bookmarks for those files automatically. However, Aspose.Pdf.Kit allows you to create bookmarks separately. You need to keep track of the page number where each PDF starts from in the concatenated output PDF and then create the bookmarks as shown on this page. Please use createBookmarkOfPage method.

I hope this helps. If you find any further questions, please do let us know.


In my application I am converting a set of file (which can be txt, doc, xls, ppt etc) into PDF and after that these PDFs are getting concatenated to a final PDF. So, its difficult to track the page number from each file conversion.

Do you have any other method by which I can maintain the bookmark in the final pdf ?

Hi Sriman,

I’m sorry to inform you that creating the bookmarks automatically is not feasible. The only workaround could be to calculate the page number on run time, as mentioned earlier.

We’re sorry for the inconvenience. If you have any further questions, please do let us know.