Page 1 of 1

Bookmarks with Childs

Posted: Mon Dec 12, 2016 10:18 am
by edvschu
Hello,

i want add bookmarks with childs into pdf. How can i do that in C#?

Best Regards,
edvschu

Re: Bookmarks with Childs

Posted: Mon Dec 12, 2016 10:53 am
by Tracker Supp-Stefan
Hello edvschu,

Please take a look at this help page describing all the methods and properties of the bookmark interface:
https://sdkhelp.pdf-xchange.com/vie ... C_Bookmark

Regards,
Stefan

Re: Bookmarks with Childs

Posted: Wed Dec 14, 2016 9:04 am
by edvschu
I found a sample for editor in help. For core i do it so:

Code: Select all

Private Sub AddBookmark()
        Dim pDoc As PDFXCoreAPI.IPXC_Document = OpenDocumentFromFile(sFileAddBookmark, pdfInst)
        If pDoc Is Nothing Then
            Return
        End If

        Dim bmRoot As PDFXCoreAPI.IPXC_Bookmark = Nothing
        Dim bmLevel1 As PDFXCoreAPI.IPXC_Bookmark = Nothing
        Dim bmLevel2 As PDFXCoreAPI.IPXC_Bookmark = Nothing
        Dim bm As PDFXCoreAPI.IPXC_Bookmark = Nothing
        Dim dest As PDFXCoreAPI.PXC_Destination = Nothing
        Dim al As PDFXCoreAPI.IPXC_ActionsList = Nothing
        Dim page As UInteger = 0

        bmRoot = pDoc.BookmarkRoot
        If bmRoot IsNot Nothing Then
            bmLevel1 = bmRoot

            page = 3
            bm = bmLevel1.AddNewChild(True)
            bm.Title = "Bookmark Level 1"
            dest = New PDFXCoreAPI.PXC_Destination
            dest.nPageNum = Convert.ToUInt32(page - 1)
            dest.nNullFlags = 15
            dest.nType = PDFXCoreAPI.PXC_DestType.Dest_XYZ
            al = pDoc.CreateActionsList()
            al.AddGoto(dest)
            bm.Actions = al

            bmLevel2 = bm

            '#################################################################

            page = 6
            bm = bmLevel2.AddNewChild(True)
            bm.Title = "Bookmark Level 2"
            dest = New PDFXCoreAPI.PXC_Destination
            dest.nPageNum = Convert.ToUInt32(page - 1)
            dest.nNullFlags = 15
            dest.nType = PDFXCoreAPI.PXC_DestType.Dest_XYZ
            al = pDoc.CreateActionsList()
            al.AddGoto(dest)
            bm.Actions = al
        End If

        pDoc.WriteToFile(sFileAddBookmark)
        pDoc.Close()
End Sub
One is still missing. How can I delete all bookmarks of a document? There is a sample for editor, but how I do this with the core?

Re: Bookmarks with Childs

Posted: Wed Dec 14, 2016 9:38 am
by Sasha - Tracker Dev Team
Hello edvschu,

Well if there is an Add method there should be a method that removes the child bookmarks. Though it's name is not Remove - the Unlink method of the IPXC_Bookmark interface allows you to remove the bookmark from it's parent.

Cheers,
Alex