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

Free Support Forum - aspose.com

Updating Named destination for links/bookmarks

Hello Team,

I want to update named destination to the existing links in pdf document.

example: if the link type is GoToAction/GoToRemoteAction with destination 12, i need to update destination as named destination(like “sample” name containes destination 5) present in the document.

after i updating named destination, the link should shows named destination as “sample” with destination 5.

please give me the hint for updating Named destination.

Vijaykumar L S


Thank you for contacting support.

Would you please share source and expected output PDF files so that we may investigate further to help you out. Moreover, hints can be found by searching over forums and in API references.


Please find the attached input and output document,
In input document one link present with action GoToAction and destination 1,

After updating named destination for that link, output document should have action has GoToAction with destination has named destination.

Regards,samplepdf Input file.pdf (37.0 KB)
samplepdf Ootput File.pdf (41.8 KB)

Vijaykumar L S


Thank you for elaborating it further.

You may create or update NamedDestinatination with below code snippet:

Document pdf = new Document();
// Create document with 10 pages
for (int i = 1; i <= 10; i++)
    Page page = pdf.Pages.Add();
    page.AddStamp(new Aspose.Pdf.TextStamp("Page " + i));
    // Named destinations for every page
    pdf.NamedDestinations.Add("Page" + i, new XYZExplicitDestination(i, 0, 600, 0.5));
for (int i = 1; i <= 10; i++)
    // Create outlines for each page
    OutlineItemCollection item1 = new OutlineItemCollection(pdf.Outlines);
    item1.Destination = new NamedDestination(pdf, "Page" + i);
    item1.Title = "Page  " + i;
// Update one of the named destinations
pdf.NamedDestinations["Page5"] = new XYZExplicitDestination(5, 0, 100, 2);
pdf.Save(dataDir + "NamedDestinaion.pdf");

You may also visit Create, Update and Extract Link for your kind reference.


i want to update named destination for that linkannotation present in the output document not for document.
Above code shows for updating named destination for the document.

Vijaykumar L S


Please refer to the code snippet below which is based on above suggestions. We have also attached a screenshot of generated PDF document which pictorially explains your requirements, that can be achieved with this code:


// Load the PDF file
Document doc = new Document(dataDir + "samplepdf Input file.pdf");
// Named destinations for the page
doc.NamedDestinations.Add("Page1" , new XYZExplicitDestination(1, 0, 600, 0.5));
// Get the first link annotation from first page of document
LinkAnnotation linkAnnot = (LinkAnnotation)doc.Pages[1].Annotations[1];
// Modification link: change link destination
GoToAction goToAction = (GoToAction)linkAnnot.Action;
// Specify the destination for link object
goToAction.Destination = new NamedDestination(doc, "Page1");
doc.Save(dataDir + "NamedDestinaion_updated.pdf");

Please share your kind feedback with us and elaborate further if you notice any problem.