Troubles with setting bookmarks

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
peterm
Posts: 3
Joined: Tue Mar 22 2005

Troubles with setting bookmarks

Post by peterm »

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
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

The new SetBookmarkXY function is part of the Document object of the CDIntf210.dll. This function receives two parameters, the X and Y coordinates of a specific page in the PDF document. The X and Y values are measured in Twips.

Hope this helps.
peterm
Posts: 3
Joined: Tue Mar 22 2005

Post by peterm »

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
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

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
Hope this helps.
Post Reply