FindDocBySrcFileName2 returning null for opened document  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
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

FindDocBySrcFileName2 returning null for opened document

Post by zarkogajic »

Hi,

I'm trying to check if a document (IPXV_Document) is already opened in the control by a file name.

I'm intercepting the e.document.beforeRunAction for a Link annotation, getting the target document if GoToR, and trying to see if the target document is already opened.

I'm using FindDocBySrcFileName2 with Get_WinPath from IPXC_FileSpec returned from Get_Target of the IPXC_Action_Goto.

FindDocBySrcFileName2 is returning null for a document that IS opened.

Also, if FindDocBySrcFileName2 is not to be used, how do I go from IPXC_FileSpec to IAFS_File (for FindDocBySrcFile) or IAFS_Name (for FindDocBySrcFileName) ?

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

Re: FindDocBySrcFileName2 returning null for opened document

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

Try using the get_DIPath method of the IPXC_FileSpec interface and then pass it to the FindDocBySrcFileName2 method with bDIPath set to true.
Also, here's how to convert string to IAFS_Name:
https://sdkhelp.pdf-xchange.com/view/PXV:IAFS_Name

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Re: FindDocBySrcFileName2 returning null for opened document

Post by zarkogajic »

Hi Alex,

Thanks.

I ended up iterating over all docs in Instance and comparing my fileName with aDoc.CoreDoc.SrcInfo.ActualFileName.

That way I can look up only for documents opened in the same frame where I want the fileName to be opened.

A question though: since there is a way to open the same document multiple times (even in the same Frame): all of those Inst.FindDocBySrcXXX will return the first document found, correct?


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

Re: FindDocBySrcFileName2 returning null for opened document

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

Nope, you can duplicate the tab - then there will be two of the same documents.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Re: FindDocBySrcFileName2 returning null for opened document

Post by zarkogajic »

Yes, and Inst.FindDocBySrcXXX will find only the "first" one of them ....

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

Re: FindDocBySrcFileName2 returning null for opened document  SOLVED

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

Of course, if you just need to see whether that document was already opened - that will work for you.

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