50
165
Document.SetBookmark Method
The SetBookmark method creates a bookmark on the specified page. Users will then be able to browse through the document
by clicking on the bookmarks tree. Bookmarks are currently available in PDF files only.
Syntax
Function SetBookmark (Page As Long, Text As String, Level As Long) As Boolean
Parameters
Page
Page number specifying the location of the bookmark
Text
Bookmark text
Level
Level of the bookmark in the bookmark tree
Return Value
It returns True if successful, and False upon failure
Example
Dim BookmarkId As Long 'local variable
'Select the PDF Printer as a destination for output.
Dim p As Printer
Dim SaveP As Printer 'Save currently selected printer
Set SaveP = Printer
For Each p In Printers 'search for our Printer and select it
If p.DeviceName = PrinterName Then
Set Printer = p
Exit For
End If
Next
SetDefaultFileName Dllpdf, "C:\Testing\PDF Converter\PDF Converter\CDINTF\Results\BookHyp.pdf"
SetFileNameOptions Dllpdf, NoPrompt + UseFileName
'Inserts a parent bookmark at the beginning
Printer.CurrentX = 200
Printer.CurrentY = 400
Printer.Print "Bookmark 1: Click to go to Bookmark 1.1"
SetBookmark Printer.hDC, 0, "Bookmark 1"
SetHyperLink Printer.hDC, "#Bookmark 1.1"
'Inserts a child bookmark
Printer.NewPage
Printer.CurrentX = 9000
Printer.CurrentY = 15000
Printer.Print "Bookmark 1.1: Rightmost hyperlink"
BookmarkId = SetBookmark(Printer.hDC, 1, "Bookkmark 1.1")
'Insert a bookmark as child for 'Bookmark 1.1'
Printer.NewPage
Printer.CurrentX = 5000
Printer.CurrentY = 10000
Printer.Print "Amyuni Site"
SetBookmark Printer.hDC, BookmarkId, "Bookmark 1.1.1"
SetHyperLink Printer.hDC, "http://www.amyuni.com"
'End document printing
Printer.EndDoc