SetBookmarkEx

 

Adds a bookmark to the specified location in the document. Can only be used with the Compact PDF, PDF, and PDF/A output file formats. Cannot be used with the PDF Image or other output file formats. The function must be called between the StartPage and EndPage GDI calls.

 

SetBookmarkEx (hDC As Long, dwParent As Integer, szTitle As String, dwPage As Integer, iFit As Integer, iLeft As Integer, iBottom As Integer, iRight As Integer, iTop As Integer, dZoom As Double) As Integer

 

Parameters

 

hDC           

-          Handle to the device context used for printing. Returned by the CreateDC Windows API function or the Graphics.GetHdc() .NET method.

dwParent   

-          Identifier of the parent bookmark returned by a previous call to SetBookmark, or 0 for top- level bookmarks.

szTitle        

-          The title of the bookmark

dwPage     

-          0-based index of the page where the bookmark will point to

iFit             

-          Specifies how the page is displayed when clicking on the bookmark. Please note the description of these values is from the PDF reference. Actual implementation depends on the PDF viewer application. Some PDF viewers may not implement all display modes. The following values are available:

 

 

BIBookmark_XYZ (0) - Display the page designated by dwPage, with the coordinates (iLeft, iTop) positioned at the upper-left corner of the window and the contents of the page magnified by the factor dZoom.

 

 

BIBookmark_Fit (1) - Display the page designated by dwPage, with its contents magnified just enough to fit the entire page within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, use the smaller of the two, centering the page within the window in the other dimension.

 

 

BIBookmark_FitH (2) - Display the page designated by dwPage, with the vertical coordinate iTop positioned at the top edge of the window and the contents of the page magnified just enough to fit the entire width of the page within the window.

 

 

BIBookmark_FitV (3) - Display the page designated by dwPage, with the horizontal coordinate iLeft positioned at the left edge of the window and the contents of the page magnified just enough to fit the entire height of the page within the window.

 

 

BIBookmark_FitR (4) - Display the page designated by dwPage, with its contents magnified just enough to fit the rectangle specified by the coordinates iLeft, iBottom, iRight, and iTop entirely within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, use the smaller of the two, centering the rectangle within the window in the other dimension.

 

 

BIBookmark_FitB (5) - Display the page designated by dwPage, with its contents magnified just enough to fit its bounding box entirely within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, use the smaller of the two, centering the bounding box within the window in the other dimension.

 

 

BIBookmark_FitBH (6) - Display the page designated by dwPage, with the vertical coordinate iTop positioned at the top edge of the window and the contents of the page magnified just enough to fit the entire width of its bounding box within the window.

 

 

BIBookmark_FitBV (7) - Display the page designated by page, with the horizontal coordinate left positioned at the left edge of the window and the contents of the page magnified just enough to fit the entire height of its bounding box within the window.

iLeft, iBottom, iRight, iTop

-          See the description of iFit. Specified in Points (1/72 inches) from the top left corner of the page.

dZoom

-          The zoom factor used for the BIBookmark_XYZ fit mode. E.g.: 1.0 means 100%, 2.0 means 200%. 0.0 means the zoom value should not be changed.

 

Return value

 

The function returns the identifier of the created bookmark, or 0 on failure.

 

Code Example

 

private static void PrintDocument1_PrintPage(object sender, PrintPageEventArgs ev)

{

 

// Create a bookmark that points to the 100:100 coordinates (in Points) of the 5. page

BlackIceDEVMODE.SetBookmarkEx((long)ev.Graphics.GetHdc(), 0, "Bookmark 1", 4, 0, 100, 0, 0, 100, 0.0);

ev.Graphics.ReleaseHdc();

 

}

 

NOTE: For 32-bit applications , use pBlackIceDEVMODE as Integer, instead of Long.