Unable to set bookmark

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
RMan
User
Posts: 221
Joined: Tue Jul 02, 2013 10:06 pm

Unable to set bookmark

Post by RMan »

We're porting some VB6 code from the old V5 SDK to the latest SDK and I've been able to add in a bookmark but I cannot set the Destination for it to a page. It appears that in the 32 bit dll when referenced in the PXC_Destination is defined as a structure maybe and not an object which is what the Bookmark.Actions.AddGoto oDest is looking gor

The C# code I was going off creates a new PDFXEdit.PXC_Destination but in VB6 we do not have the NEW option available for the PXC_Destination.

PDFXEdit.PXC_Destination dest = new PDFXEdit.PXC_Destination();

TrackerEditor_Destination.jpg
Here's the VB6 code that will create a new blank document and add the bookmark in which works, I just can't set the destination of the bookmark to a page.


Private Sub Command1_Click()

Dim pxvInst As PXV_Inst
Dim pxcInst As PXC_Inst

Set pxvInst = New PXV_Inst
Call pxvInst.Init(Nothing, "")

Set pxcInst = pxvInst.GetExtension("PXC")

Dim pxcDoc As IPXC_Document

Set pxcDoc = pxcInst.NewDocument
Dim oPXCRect As PXC_Rect
oPXCRect.Right = 1000
oPXCRect.bottom = 1000
pxcDoc.Pages.AddEmptyPages 0, 3, oPXCRect

Dim oBookmarkRoot As IPXC_Bookmark
Dim oBookmarkNew As IPXC_Bookmark

Set oBookmarkRoot = pxcDoc.BookmarkRoot

Set oBookmarkNew = oBookmarkRoot.AddNewChild(True)
oBookmarkNew.Title = "Test Title"
pxcDoc.WriteToFile App.Path & "\TestBookmark.pdf"


Dim oDest As PXC_Destination
oDest.nPageNum = 2
oDest.nType = Dest_Fit

'***********************************************************************
'THIS IS WHERE COMPILE ERROR IS
'Compile Error: User-defined type may not be passed ByVal
'***********************************************************************
oBookmarkNew.Actions.AddGoto oDest

pxcDoc.WriteToFile App.Path & "\TestBookmarkWithGoto.pdf"

End Sub
RMan
User
Posts: 221
Joined: Tue Jul 02, 2013 10:06 pm

Re: Unable to set bookmark

Post by RMan »

Here's a sample VB6 project as I also in some more testing found another bug with VB6, Trying to access the Actions from the Bookmark object will lock up the program completely.
DestAsReference.zip
(11.97 KiB) Downloaded 63 times
lCount = oBookmark.Actions.Count
RMan
User
Posts: 221
Joined: Tue Jul 02, 2013 10:06 pm

Re: Unable to set bookmark

Post by RMan »

Is there anyway to run a Javascript command from the IPXC_Document to add in the bookmark from VB6 since the PDFXEdit.PXC_Destination doesn't appear to be working?
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Unable to set bookmark

Post by Tracker Supp-Stefan »

Hello RMan,

I've asked a colleague from the dev team to take a look at your topic and assist, however they said that they will need to install a VB6 environment first to be able to test and reply you accordingly!

Kind regards,
Stefan
RMan
User
Posts: 221
Joined: Tue Jul 02, 2013 10:06 pm

Re: Unable to set bookmark

Post by RMan »

Thanks. I did find a workaround by using the IPXS_PDFVariant and the various Dictionary and Array functions to add the correct information onto the Bookmark Object that was created.

Expanding on the code I posted before this is what I did

'First get the PDF Object for the Bookmark we added
Dim oPDFObject As IPXS_PDFVariant
Set oPDFObject = oBookmarkNew.PDFObject

'Create the New "D" Dictionary
Dim oNewDict As IPXS_PDFVariant
Set oNewDict = p_pxsInst.NewVar_Dict
Call oNewDict.Dict_SetName("S", "GoTo")


'Get the PDF Object for the Page we want
Dim oPage As IPXS_PDFVariant
'Page Number is 0 based
Set oPage = p_pxcDoc.Pages.item(lGotoPage0Based).PDFObject


'Create the "D" Array which tells it the destination
Dim oNewArray As IPXS_PDFVariant
Set oNewArray = p_pxsInst.NewVar_Array()
Call oNewArray.Arr_Insert(oPage)
'Fit Page
Call oNewArray.Arr_InsertName("Fit")
'
'This call adds the "D" array to the New Dictionary
Call oNewDict.Dict_Set("D", oNewArray)

'This is the call that adds the "A" dictionary to the bookmark
Call oPDFObject.Dict_Set("A", oNewDict)
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Unable to set bookmark

Post by Tracker Supp-Stefan »

Hello RMan,

Glad to hear you found a working solution and thanks for sharing it with us all!

Kind regards,
Stefan
Post Reply