Share via

Add bookmarks to a PDF using Foxit ActiveX SDK pro (VBA)

Anonymous
2022-05-13T14:06:49+00:00

Does anybody have experience with Foxit ActiveX SDK pro in Excel VBA?

I would like to add bookmarks to specific pages in a PDF using Foxit ActiveX SDK pro in Excel VBA.

Can somebody please help?

The code I have for now is this, but the last part does not work:

Sub Test_Foxit_Open_PDF_in_Userform() 

    'This will open a PDF in a userform (in excel), insert another existing PDF,
    'add a watermark and save as another PDF
    'Dim PDFPrinter As New FoxitPDFSDKProLib.FoxitPDFSDK 

    Dim sPDFfile As String, sPDFfile2 As String 

    Dim sSaveAsFileName As String 

    Dim IsFileOpen As Boolean 

    Dim lPageCount As Long 

    Dim bResult As Boolean 

    sPDFfile = "C:\Users\frank.van.eygen\Documents\PDF files\Exact3.pdf" 

    sPDFfile2 = "C:\Users\frank.van.eygen\Documents\PDF files\Test Frank.pdf" 

    sSaveAsFileName = "C:\Users\frank.van.eygen\Documents\PDF files\Test_Foxit.pdf" 

    Load UserForm1 

    IsFileOpen = UserForm1.FoxitPDFSDK1.OpenFile(sPDFfile, "") 

    lPageCount = UserForm1.FoxitPDFSDK1.PageCount 

    bResult = UserForm1.FoxitPDFSDK1.InsertPage(lPageCount, sPDFfile2, "", "0") 

    bResult = UserForm1.FoxitPDFSDK1.AddWaterMark(1, "This is a watermark", 50, 200, 90, ColorConstants.vbCyan, 0, 100, 45) 

    UserForm1.FoxitPDFSDK1.SaveAs (sSaveAsFileName) 

'adding a bookmark does not work
    'UserForm1.FoxitPDFSDK1.SetBookmarkContextMenuString ("Page1") 

    'UserForm1.FoxitPDFSDK1.GetOutlineFirstChild() 

    UserForm1.Show 

    Unload UserForm1 

End Sub
Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2022-05-16T06:31:18+00:00

    I suggest to ask that question here to IMHO have a much better chance to get an adequate answer.

    https://forums.foxitsoftware.com/forum/portable-document-format-pdf-tools/sdk-dll-or-activex

    Andreas.

    Thank you Andreas. I'll give that a try.

    0 comments No comments
  2. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2022-05-14T07:14:00+00:00

    I suggest to ask that question here to IMHO have a much better chance to get an adequate answer.

    https://forums.foxitsoftware.com/forum/portable-document-format-pdf-tools/sdk-dll-or-activex

    Andreas.

    0 comments No comments