Help with DocInfoBar

PDF-XChange Editor SDK for Developers

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

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.
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Help with DocInfoBar

Post by docu-track99 »

Hi folks,

I'm encountering an issue with DocInfoBar. I'm trying to add a button ton the bar, however an OutOfMemoryException is being thrown. Here is my code I've been playing with:

Code: Select all

    Private Sub cmdDocInfoBar_Click(sender As System.Object, e As System.EventArgs) Handles cmdDocInfoBar.Click
        If pdfCtrl.Inst.ActiveDoc IsNot Nothing Then

            Dim Doc As IPXV_Document = pdfCtrl.Inst.ActiveDoc

            Dim InfoBar As IPXV_DocInfoBar = Doc.InfoBar
            Dim MyIcon As IUIX_Icon = GetIcon(PathToImageFile)

            InfoBar.AddSpan(1, 1, 125)
            InfoBar.AddButton(1, 1, "Text", "Tooltip", MyIcon)

            InfoBar.Hidden = False
            InfoBar.Minimized = False

        End If
    End Sub
Here is my GetIcon method:

Code: Select all

Public Function GetIcon(IconPath As String) As PDFXEdit.IUIX_Icon
        Dim Icon As PDFXEdit.IUIX_Icon = Nothing

        If System.IO.File.Exists(IconPath) Then
            Dim name As PDFXEdit.IAFS_Name = fsInst.DefaultFileSys.StringToName(IconPath)
            Dim file As PDFXEdit.IAFS_File = fsInst.DefaultFileSys.OpenFile(name, CInt(PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_Read) Or CInt(PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_ShareRead))
            Icon = uiInst.CreateIconFromIStream(file.GetStream())
        End If

        Return Icon

    End Function
The error occurs on the InfoBar.AddButton(1, 1, "Text", "Tooltip", Icon) line. FYI, my icons are fine when I add them to cmds.

Regards,
Doc.It Development
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Help with DocInfoBar

Post by Sasha - PDF-XChange »

Hello docu-track99,

I just checked our inner code. There was a minor bug in the AddButton method that's fixed now and will be available in the next release.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Re: Help with DocInfoBar

Post by docu-track99 »

Hi Alex,

This is working well now and I've been able to add a button to an info bar but I'm looking for some guidance on the following minor issue.

I would like to add two buttons to the infobar, much like the infobar that appears by default from the control when you place a signature/initial on the document. When I use the following code to add two buttons, I only see the second button but not the first.

Code: Select all

 Private Sub DisplaySignaturesDocInfoBar()
        Try
            If pdfCtrl.Inst.ActiveDoc IsNot Nothing Then

                Dim Doc As IPXV_Document = pdfCtrl.Inst.ActiveDoc
                Dim InfoBar As IPXV_DocInfoBar = Doc.InfoBar

                If Not Doc.InfoBar.HasSpan(Doc.ID) Then

                    InfoBar.AddSpan(Doc.ID, 100, 15247393)
                    InfoBar.SetText(Doc.ID, "MyText")
                    InfoBar.AddButton(Doc.ID, enumInfoBarButton.Yes, "1Yes", "Click 'yes'", Nothing)
                    InfoBar.AddButton(Doc.ID, enumInfoBarButton.No, "1No", "Click 'no'", Nothing)
                    InfoBar.HighlightSpan(Doc.ID)
                    InfoBar.Callbacks = m_oDocInfoBarCallbacks
                    InfoBar.Hidden = False
                    InfoBar.Minimized = False

                End If
            End If

        Catch ex As Exception
            mWriteLog(1, "DisplaySignaturesDocInfoBar(): There was an error in displaying the stamps info bar.")
            mGenericError(ex)
        End Try
    End Sub
Thanks,
Doc.It Development
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Help with DocInfoBar

Post by Sasha - PDF-XChange »

Hello docu-track99,

It seems that there's some sort of a bug when adding even number of buttons to the document's info bar - we'll investigate this and will try to fix it.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Re: Help with DocInfoBar

Post by docu-track99 »

Hi Alex,

OK, thanks. I did try with 3 buttons and it works fine. I also tried adding 3 buttons and then removing 1 of them, but this ultimately removes all buttons, maybe due to another bug or the same one.

Regards,
Doc.It Development
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Help with DocInfoBar

Post by Sasha - PDF-XChange »

Yes - this needs to be investigated. The problem is that this code was never used before as a part of the Editor's functionality thus these problems occur. We will try to fix them asap.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ