AddBookmark

<< Click to Display Table of Contents >>

Navigation:  PDF Export >

AddBookmark

Previous pageReturn to chapter overviewNext page

[VPE Professional Edition and above]

Adds a bookmark to the document: a PDF document may optionally display a document outline on the screen, allowing the user to navigate interactively from one part of the document to another. The outline consists of a tree-structured hierarchy of bookmark items, which serve as a "visual table of contents" to display the document’s structure to the user. Bookmarks are displayed in the left tree-view of Acrobat Reader.

The bookmark will have the currently assigned destination, style and color (see SetBookmarkDestination(), BookmarkStyle, BookmarkColor).

The target page for the destination is always the currently active page of the VPE document as you call this method.

In order to create a hierarchical tree structure, you can supply a parent bookmark as parent, i.e. the added bookmark will be a child of the supplied parent bookmark. To add a bookmark to the top-level of the hierarchy, specify a value of null for the parent.

The AddBookmark method returns a handle to the newly created bookmark, which can be used as parent for subsequent calls.

method TVPEBookmark [pointer] VPE.AddBookmark(

TVPEBookmark [pointer] Parent,

string Title

)

TVPEBookmark [pointer] Parent

the parent bookmark or null for a top-level bookmark

string Title

the title of the bookmark

Returns:

the newly created bookmark, which can be used as parent for subsequent calls

Remarks:

Bookmarks are not shown within VPE documents. They are stored internally and are exported to PDF documents only.

 
Bookmarks are not stored within VPE document files. If you write a VPE document that contains bookmarks to a file, read the file later into memory and export it to PDF, the bookmarks are omitted. For the same reason, bookmarks will be missing in exported PDF files, if the VPE source document is created stream-based by using SwapFileName.

Example:

VCL:

// Bold and Italic styles will work only with PDF 1.4, activate it:

VPE.PDFVersion = VPE_PDF_ACROBAT_5

 

// Output some text on the current page:

VPE.VpePrint(1, 1, "Introduction")

 

// Set the style for newly added bookmarks to bold, italic, open:

VPE.BookmarkStyle = VBOOKMARK_STYLE_BOLD + VBOOKMARK_STYLE_ITALIC + VBOOKMARK_STYLE_OPEN

 

// Set the destination type for newly added bookmarks:

VPE.SetBookmarkDestination(VBOOKMARK_DEST_FIT, 0, 0, 0, 0, 1)

 

// Add a new bookmark to the top-level of the hierachy:

Pointer ParentBookmark = VPE.AddBookmark(0, "Introduction")

 

// Append a new page to the VPE document:

VPE.PageBreak();

 

// Output some text on the current page:

VPE.VpePrint(1, 1, "Bookmarks explained")

 

// Add a new bookmark as child of the previously inserted bookmark.

// It will have the currently adjusted style, color and destination:

VPE.AddBookmark(ParentBookmark, "Bookmarks explained")

 

 

ActiveX, .NET, Java, …:

// Bold and Italic styles will work only with PDF 1.4, activate it:

VPE.PDFVersion = PDFVersion.Acrobat5

 

// Output some text on the current page:

VPE.Print(1, 1, "Introduction")

 

// VB .NET

// Set the style for newly added bookmarks to bold, italic, open:

VPE.BookmarkStyle = BookmarkStyle.Bold + BookmarkStyle.Italic + BookmarkStyle.Open

 

// C# (must use | operator)

// Set the style for newly added bookmarks to bold, italic, open:

VPE.BookmarkStyle = BookmarkStyle.Bold | BookmarkStyle.Italic | BookmarkStyle.Open

 

// Set the destination type for newly added bookmarks:

VPE.SetBookmarkDestination(BookmarkDestination.Fit, 0, 0, 0, 0, 1)

 

// Add a new bookmark to the top-level of the hierachy:

// (for Visual Basic .NET use "Nothing" instead of "null")

TVPEBookmark ParentBookmark;

ParentBookmark = VPE.AddBookmark(null, "Introduction")

 

// Append a new page to the VPE document:

VPE.PageBreak();

 

// Output some text on the current page:

VPE.Print(1, 1, "Bookmarks explained")

 

// Add a new bookmark as child of the previously inserted bookmark.

// It will have the currently adjusted style, color and destination:

VPE.AddBookmark(ParentBookmark, "Bookmarks explained")

 

For Visual Basic 6.0 use “Nothing” instead of “null” in the call to AddBookmark().