Table of Contents
- Getting Started
- EO.Pdf
- Overview
- Installation and Deployment
- Using HTML to PDF
- Using PDF Creator
- Using PDF Creator
- Getting Started
- Advanced Formatting Techniques
- Interactive Features
- Low Level Content Objects
- Working with Existing PDF Files
- Using in Web Application
- Advanced Topics
- EO.Web
- EO.WebBrowser
- EO.Wpf
- Common Topics
- Reference
Creating Bookmarks |
Overview
A PDF document may optionally include a bookmark tree allowing the user to navigate interactively from one part of the document to another. The bookmark tree consists of a tree-structured hierarchy of bookmarks.
Creating Top Level Bookmark
Follow these steps to create a top level bookmark:
-
Create a PdfBookmark object:
//Create a PdfBookmark object with text "Chapter 1" PdfBookmark bookmark = new PdfBookmark("Chapter 1");
-
Set the bookmark's Destination property to a PdfDestination object. The easiest way to create a PdfDestination object is to call AcmContent's CreateDestination to create a PdfDestination object that represents the top position of the content. Note that you can only call this function after the content has been rendered.
//Initializes the bookmark's Destination property bookmark.Destination = content.CreateDestination();
-
Add the bookmark to the document's catalog:
//Add it as a top level bookmark, "doc" //is a PdfDocument object doc.Bookmarks.Add(bookmark);
Creating Child Bookmark
Creating a child bookmark is the same as creating a top level bookmark, except that instead of adding the bookmark into the document's catalog, the new bookmark is added to its parent bookmark's ChildNodes collection:
//Create a child bookmark under "parentBookmark"
parentBookmark.ChildNodes.Add(childBookmark);