Hi there,
I have a requirement where I need to add named destinations to an existing pdf. I was able to use the following chunk of code that I found online to add the named destinations
private static void createPdfWithNamedDestinations()
{
Document pdf = new Document();
// Create document with 100 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 (two outlines for every page)
OutlineItemCollection item1 = new OutlineItemCollection(pdf.Outlines);
item1.Destination = new NamedDestination(pdf, “Page” + i);
item1.Title = "Page " + i + “(1)”;
pdf.Outlines.Add(item1);
OutlineItemCollection item2 = new OutlineItemCollection(pdf.Outlines);
item2.Destination = new NamedDestination(pdf, "Page" + i);
item2.Title = "Page " + i + "(2)";
pdf.Outlines.Add(item2);
}
// Let's update on of the named destinations
pdf.NamedDestinations["Page5"] = new XYZExplicitDestination(5, 0, 100, 2);
pdf.Save("result.pdf");
}
However, the issue is, when I open the saved pdf on Adobe Acrobat, I don’t see any nameddestinations created on the named destinations tab.
Attached is the generated pdf from this sample code.
Please help me figure out what I am doing wrong.
Thanks,
Rashmi Dahal
result.pdf (16.1 KB)