Hi,
I have an existing pdf with bookmarks and I want to add a new root bookmark e.g. the filename and add existing under that, how can I do that? any easy way?
e.g. currently:-
Example 1
--- Example 1 child
Example 2
Example 3
need:-
bookmark.pdf
---Example 1
------Example 1 child
---Example 2
---Example 3
c# - currently just add's it at the end.
Document doc = new Document("bookmark.pdf");
// Create new bookmark.
OutlineItemCollection newBookmark = new OutlineItemCollection(doc.Outlines);
newBookmark.Title = "bookmark.pdf";
newBookmark.Destination = new Aspose.Pdf.InteractiveFeatures.FitHExplicitDestination(doc.Pages[12], 792);
// Save previous bookmarks list.
IList prevBookmarks = new List();
foreach (OutlineItemCollection bookmark in doc.Outlines)
{
bookmark.Add(newBookmark); // adding new bookmark
prevBookmarks.Add(bookmark);
}
// Remove existing bookmarks.
doc.Outlines.Delete();
// Add updated bookmarks.
foreach (OutlineItemCollection prevBookmark in prevBookmarks)
{
doc.Outlines.Add(prevBookmark);
}
doc.Save("bookmark_out.pdf");