Change the Tab description  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, 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
bpatel
User
Posts: 42
Joined: Thu Jan 05, 2017 4:53 pm

Change the Tab description

Post by bpatel »

Hi,

Could you please let me know how to change the description on the document tab?
I load the document using the following code:
oPDFCtrl.OpenDocFromPath(strPDFFileName)

Then I have the following code:
doc = oPDFCtrl.Doc
doc.CoreDoc.Info.InfoStr(PXC_DocumentInfoKey.DocInfo_Title) = "TEST 123"


But this doesn't change the description of the tab. I still see the file name.
Please provide me some code snippet to solve this.

Thanks,
Bijalkumar Patel
Logistics Health, Inc.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change the Tab description  SOLVED

Post by Sasha - Tracker Dev Team »

Hello bpatel,

You should change the document's properties so that it would show the custom title, not the file name. To do that, you will need to use this:

Code: Select all

Doc.CoreDoc.Props.set_ViewPrefFlag(PDFXEdit.PXC_DocumentViewFlags.DocViewFlag_DisplayDocTitle, true);
Doc.CoreDoc.SrcInfo.CustDispTitle = "Custom Title"; Doc.CoreDoc.Props.set_ViewPrefFlag(PDFXEdit.PXC_DocumentViewFlags.DocViewFlag_DisplayDocTitle, true);
var evtID = pdfCtl.Inst.Str2ID("e.document.propsChanged", false);
IntPtr unkPtr = System.Runtime.InteropServices.Marshal.GetIUnknownForObject(Doc);
PDFXEdit.IEvent evt = Doc.EventServer.CreateNewEvent(evtID, (uint)unkPtr, (uint)PDFXEdit.PXC_DocumentViewFlags.DocViewFlag_DisplayDocTitle);
Doc.EventServer.FireEvent(evt, Doc);
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
bpatel
User
Posts: 42
Joined: Thu Jan 05, 2017 4:53 pm

Re: Change the Tab description

Post by bpatel »

Thank you Alex!
It works as expected now.

Thanks,
Bijalkumar Patel
Logistics Health, Inc.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change the Tab description

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jlucas
User
Posts: 2
Joined: Wed Jun 06, 2018 6:28 am

Re: Change the Tab description

Post by jlucas »

Hello, It appears that the example provided is prone to Arithmetic overflow exception when you cast to the IntPtr to an UInt. I think this is because IntPtr can be larger the max value for UInt (32 bit).

Code: Select all

IntPtr unkPtr = System.Runtime.InteropServices.Marshal.GetIUnknownForObject(Doc);
PDFXEdit.IEvent evt = Doc.EventServer.CreateNewEvent(evtID, (uint)unkPtr, (uint)PDFXEdit.PXC_DocumentViewFlags.DocViewFlag_DisplayDocTitle);
Is there another way to show a custom title? Is this a possible bug?

thanks,

-jlucas
-Logistics Health Incorporated.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change the Tab description

Post by Sasha - Tracker Dev Team »

Hello jlucas,

If you are using the x64 then the ulong should be used in this case.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jlucas
User
Posts: 2
Joined: Wed Jun 06, 2018 6:28 am

Re: Change the Tab description

Post by jlucas »

Thanks for the Reply Alex,

We are using 32bit dll. Okay I looked at it a bit more, the IntPtr in our application is a Size of 4 (32bit) IntPtr. So the cast should be good then, unless if IntPtr is a negative. So I am thinking the the GetIUnknownForObject is returning a negative which then causes the Arithmetic overflow exception when cast it to UInt. Below is our code, similar to the previous example. Could their be something up with the Doc? Is there anything that we should check before doing this logic? I think going forward we will at least to a UInteger.TryParse check first.

Code: Select all

                    oPDFCtrl.OpenDocFromPath(strPDFFileName, m_oReadOnlyParams)
                    doc = oPDFCtrl.Doc

                    'Display the OrderItemDocId instead of the PDFFileName in the editor's document tab bar
                    doc.CoreDoc.SrcInfo.CustDispTitle = kvpOIDPDFFile.Key.ToString
                    Dim evtID = oPDFCtrl.Inst.Str2ID("e.document.propsChanged", False)
                    Dim unkPtr As IntPtr = System.Runtime.InteropServices.Marshal.GetIUnknownForObject(doc)
                    Dim evt As PDFXEdit.IEvent = doc.EventServer.CreateNewEvent(evtID, CUInt(unkPtr), PXC_DocumentViewFlags.DocViewFlag_DisplayDocTitle)
                    doc.EventServer.FireEvent(evt, doc)
Thanks,

jlucas
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change the Tab description

Post by Sasha - Tracker Dev Team »

Hello jlucas,

We will need a working sample project and detailed instructions to recreate this.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
tnickel
User
Posts: 7
Joined: Thu Nov 29, 2018 7:52 pm

Re: Change the Tab description

Post by tnickel »

Hello,

I work with Jade and Bijal. It seems the issue is that we are getting a 64 bit pointer back when making the call to

Code: Select all

Marshal.GetIUnknownForObject
, but this only happens when our application is being hosted through RD Web Access. An example value I logged was 830407840720. Other hosting options we have and directly accessing the application executable does not result in the same issue (i.e pointer returned has a 32 bit value).

We are in the process of upgrading to the 64 bit DLL. However, unless I am missing something, in the x64 DLL the method signature of IEventServer.CreateNewEvent still has nParam1 typed as UInteger. I tried passing this 64 bit pointer typed as a ULong to IEventServer.CreateNewEvent. I did not get an error, however the titles still did not show.

Please advise on how to get this to work with 64 bit pointers
Attachments
Titles not changed
Titles not changed
Capture1.PNG (10.53 KiB) Viewed 3359 times
Code snippet
Code snippet
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change the Tab description

Post by Sasha - Tracker Dev Team »

Hello tnickel,

Well I do not know what did you achieve with that piece of code previously, but I tried this code snippet and it worked smoothly:

Code: Select all

Dim nEventID = pdfCtl.Inst.Str2ID("e.document.propsChanged", False)
Dim evt = pdfCtl.Doc.EventServer.CreateNewEvent(nEventID, PDFXEdit.PXV_ChangeDocPropsFlag.CDPF_Author)
pdfCtl.Doc.EventServer.FireEvent(evt, pdfCtl.Doc)
Also, be sure to read the description to the event's parameters:
https://sdkhelp.pdf-xchange.com/vi ... opsChanged

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
tnickel
User
Posts: 7
Joined: Thu Nov 29, 2018 7:52 pm

Re: Change the Tab description

Post by tnickel »

I will try that and let you know how it works. Just curious though, if a managed pointer to the PXV_Document is not required to pass to the IEventServer.CreateNewEvent, why did you suggest that in the first code snippet you gave to Bijal? Is that an artifact from an older version of the SDK?
tnickel
User
Posts: 7
Joined: Thu Nov 29, 2018 7:52 pm

Re: Change the Tab description

Post by tnickel »

thanks Alex. The new code snippet you gave us seems to be working for all our hosted environments
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change the Tab description

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply