Adds a bookmark pointing to the current page.




virtual int AddBookmark(string path, bool open)

[Visual Basic]
Overridable Function AddBookmark(path As String, open As Boolean) As Integer



Name Description

The path to the bookmark.

open Whether the bookmark should be displayed open (expanded) or closed (collapsed).
return The Object ID of the newly added Bookmark Object.




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 function multiple times.

This function returns the Object ID of the newly added Bookmark Object.

Hyperlinks. Sometimes you may wish to insert bookmarks which link to an external web page specified using a URI or URL. You can do this using code of the following form.

static int AddBookmarkToUri(Doc doc, string bookmark, string uri) {
  int id = doc.AddBookmark(bookmark, true);
  doc.SetInfo(id, "/Dest:Del", ""); // remove link to page and add link to url
  doc.SetInfo(id, "/A", "<< /Type /Action /S /URI /URI () >>");
  doc.SetInfo(id, "/A/URI:Text", uri);
  return id;




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 are visible because the chapter pages were added in a collapsed state.

Doc theDoc = new Doc();
theDoc.FontSize = 64;
string theSection, theChapter, theSubject;
for (int i = 1; i < 3; i++) {
  theDoc.Page = theDoc.AddPage();
  theSection = i.ToString() + " Section";
  theDoc.AddBookmark(theSection, true);
  for (int j = 1; j < 5; j++) {
    theDoc.Page = theDoc.AddPage();
    theChapter = theSection + "\\" + j.ToString() + " Chapter";
    theDoc.AddBookmark(theChapter, false);
    for (int k = 1; k < 6; k++) {
      theDoc.Page = theDoc.AddPage();
      theSubject = theChapter + "\\" + k.ToString() + " Subject";
      theDoc.AddBookmark(theSubject, true);

[Visual Basic]
Dim theDoc As Doc = New Doc()
theDoc.FontSize = 64
Dim theSection, theChapter, theSubject As String
For i As Integer = 1 To 2
  theDoc.Page = theDoc.AddPage()
  theSection = i.ToString() + " Section"
  theDoc.AddBookmark(theSection, True)
  For j As Integer = 1 To 4
    theDoc.Page = theDoc.AddPage()
    theChapter = theSection + "\" + j.ToString() + " Chapter"
    theDoc.AddBookmark(theChapter, False)
    For k As Integer = 1 To 5
      theDoc.Page = theDoc.AddPage()
      theSubject = theChapter + "\" + k.ToString() + " Subject"
      theDoc.AddBookmark(theSubject, True)