Hello,
Hi Eric,
Thanks for contacting support.
Please visit the following link for required information on Import and Export Bookmarks. The code snippet in shared link shows the steps to import the bookmark in existing PDF file and in case you need to import it into new PDF document, you can create a document from scratch using Document instance, add page object to pages collection of PDF file, pass this object to PdfBookmarkEditor class and then import the bookmarks inside it.
[C#]
// Create Document instance
Document doc = new Document();
// add page to PDF file
doc.Pages.Add();
// Create PdfBookmarkEditor class>
Aspose.Pdf.Facades.PdfBookmarkEditor
bookmarkEditor = new Aspose.Pdf.Facades.PdfBookmarkEditor();
// Open PDF file
bookmarkEditor.BindPdf(doc);
// Import bookmarks
bookmarkEditor.ImportBookmarksWithXML(dataDir + “bookmarks.xml”);//Save updated PDF file
bookmarkEditor.Save(dataDir + "ImportFromXML_out.pdf");
Thank you Nayyer!
And perhaps I should explain the scope of my project, maybe it will help.
I am all set on this, I was able to get my code working. The piece I was missing was while looping through the Aspose.Pdf.Facades.Bookmark collection, I had to use the PageNumber and Destination to access the Aspose.Pdf.Page to add it to the new Aspose.Pdf.Document.
Hi Eric,
Thanks for sharing the details.
Apart from earlier shared approach of exporting Bookmarks to XML format, you can traverse through the bookmarks collection and get information related to specific bookmark. The Bookmarks are fetched in OutlineItemCollection and you can access specific object. For more information, please visit Get Bookmarks from a PDF Document.
Once you have the information, you may follow the instructions specified over following link on how to Add a Bookmark to a PDF Document.
Should you have any further query, please feel free to contact.
Hi Eric,eforden:
I am all set on this, I was able to get my code working. The piece I was missing was while looping through the Aspose.Pdf.Facades.Bookmark collection, I had to use the PageNumber and Destination to access the Aspose.Pdf.Page to add it to the new Aspose.Pdf.Document.