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

Free Support Forum - aspose.com

Local Hyperlinks don't work when concatenating documents

Hi

When I use your example [here] and create a 2 page document with a link to page 7 on the first page, if I then use

pdfEditor.Concatenate(inputStream1, inputStream2, outputStream);

to concatenate that file with another, any arbitrary PDF longer than 7 pages, the link to page 7 doesn’t work.

Is it possible to create an index document with links to pages that don’t exist in the current document and then concatenate that document with the actual document and get working links.

I ask because due to memory constraints we may have to generate and optimize PDFs in batches and then concatenate them together and while the Bookmarks/Outlines work I’m not sure how to get a Table Of Contents with hyperlinks to work.

Thanks

Si

@simon.fairey

Thanks for contacting support.

There is a way where you can achieve your above requirement by adding link annotations in the page and specifying its Action as GoToAction() with an integer value of page number. Please check following sample code snippet which adds a link to non-existing page and later adds that page into PDF.

Document doc = new Document();
Page page = doc.Pages.Add();
LinkAnnotation link = new LinkAnnotation(page, new Rectangle(100, 100, 200, 200));
link.Contents = "Sample Link";
link.Action = new GoToAction(2);
page.Annotations.Add(link);
doc.Save(dataDir + "singlePage.pdf");
doc = new Document(dataDir + "singlePage.pdf");
doc.Pages.Add();
doc.Save(dataDir + "twoPages.pdf");

However, please note that GoToAction(PageNumber) method is not recommended and soon going to be discontinued because it creates issue when you re-save file using Adobe Reader. Instead GoToAction(Aspose.Pdf.Page) is recommended which takes a whole Page object as an argument.

As per our understandings, you need to preserve local links while splitting the document and later need them to work correctly when you perform concatenation. Would you please share some sample PDF document(s) along with complete sample code snippet which is able to reproduce the issue you are facing. We will test the scenario in our environment and address it accordingly.