There is a method "SetBookmarkXY" in the CDIntfEx.Document object interface that, I think is supposed to inject bookmarks in the open document for a certain possition in the text. Unfortunatelly the method is not documented in the 'Common Driver Interface250.pdf', and also I don't see it working in version 2.5b that I am currently trying to use for that.
Could somebody help me with that?. Thank you
Troubles with setting bookmarks
The method also receives the 'relative' level, page, and text of the bookmark.
The weird think is that although the method call doesn't fail, the actual outline item is not shown in the PDF document. I have verified the Outlines dictionary in the resulting file, and it seems that the outline items (the bookmarks) are there but with missing information. Based on the PDF Reference, the dictionary of such an object must also have the following entries: /Parent, /Count and /Next.
Is there any workarround for this issue?
Thank you
The weird think is that although the method call doesn't fail, the actual outline item is not shown in the PDF document. I have verified the Outlines dictionary in the resulting file, and it seems that the outline items (the bookmarks) are there but with missing information. Based on the PDF Reference, the dictionary of such an object must also have the following entries: /Parent, /Count and /Next.
Is there any workarround for this issue?
Thank you
Hello,
Please find here a VB sample on using SetBookmark and SetBookmarkXY.
The values passed to SetBookmarkXY are in TWIPS
Hope this helps.
Please find here a VB sample on using SetBookmark and SetBookmarkXY.
The values passed to SetBookmarkXY are in TWIPS
Code: Select all
Private Sub Command1_Click()
Dim pdfDoc As New CDIntfEx.Document
'////////////////////////////////////////////////////////////////////////
'Parameters:
'Page :
' page number on which to set the bookmark. Page numbers start with page 1
'Text :
' bookmark title.
'Level :
' determines if this bookmark is at the same level
' as the previous one (value = 0),
' at a child level (value = 1),
' or at a parent level (value = -1).
pdfDoc.Open App.Path & "\fourPage.pdf"
'Clear any previous bookmarks in case they exist.
pdfDoc.ClearBookmarks
'set first bookmark with level zero (parent)
pdfDoc.SetBookmark 1, "bookmark page 1", 0
' set child bookmark called " Submark 1-1" one on a sublevel
pdfDoc.SetBookmark 2, "bookmark page 2", 1
' set the other bookmarks on the same level of "Submark 1-1"
'pdfDoc.SetBookmark 3, "bookmark page 3", 1
'Function SetBookmarkXY(Page As Long, xPos As Long, yPos As Long, Text
As String, Level As Long) As Boolean
'xPos and yPos are in Twips
pdfDoc.SetBookmarkXY 3, 10204, 15307, "Sample Bookmark", 1
' set the other bookmarks on the parent level of "Submark 1-2"
pdfDoc.SetBookmark 4, "bookmark page 4", -2
pdfDoc.Save App.Path & "\pagebookmarks.pdf"
Set pdfDoc = Nothing
End Sub