Adds a bookmark pointing to the current page.

 

   

Syntax
 

BookmarkID = Doc.AddBookmark(Path, Open)

 

   

Params
 
Name Type Description
Path String The path to the bookmark.
Open Boolean Whether the bookmark should be displayed open (expanded) or closed (collapsed).
BookmarkID Long The Object ID of the newly added Bookmark object.

 

   

Notes
 

Adds a bookmark which points to the current page.

Bookmarks are specified as paths in much the same way as file paths. Headings and subheadings are separated by a backslash character. For example:

"1. Introduction\1.1 Aim and Methods\1.1.3 Diagrams"

When a bookmark is added, intermediate headings and subheadings will be created if they do not already exist.

To add multiple bookmarks all referring to the same page, simply call the AddBookmark method multiple times.

This method returns the Object ID of the newly added Bookmark object.

 

   

Example
 

The following code adds a sequence of pages with a nested sequence of bookmarks. The image shows the appearance of the document outline. Note that none of the subject pages is visible because the chapter pages have been added in the collapsed state.

Set theDoc = Server.CreateObject("ABCpdf10.Doc")
theDoc.FontSize = 64
For i = 1 To 3
  theDoc.Page = theDoc.AddPage()
  theSection = i & " Section"
  theDoc.AddText theSection
  theDoc.AddBookmark theSection, True
  For j = 1 To 5
    theDoc.Page = theDoc.AddPage()
    theChapter = theSection & "\" & j & " Chapter"
    theDoc.AddText theChapter
    theDoc.AddBookmark theChapter, False
    For k = 1 To 6
      theDoc.Page = theDoc.AddPage()
      theSubject = theChapter & "\" & k & " Subject"
      theDoc.AddText theSubject
      theDoc.AddBookmark theSubject, True
    Next
  Next
Next
theDoc.Save "c:\mypdfs\docaddbookmark.pdf"


docaddbookmark.pdf