Multi tab: assign custom object to each tab/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: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Multi tab: assign custom object to each tab/document

Post by zarkogajic »

Hi devs,

In multi tab mode (Docs.SingleWnd = false), how do I assign a custom object to each tab / document loaded?

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

Re: Multi tab: assign custom object to each tab/document

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

What do you mean by custom object?

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

Re: Multi tab: assign custom object to each tab/document

Post by zarkogajic »

Hi Alex,

Say I have a custom object (instance of my custom class) where a PDF document (its path location) is only one property of that object. I will actually have a list of such objects and it could be possible that two (different) objects have the same file for their PDF property.

I then use the SDK to display the PDF for my object. When I load the PDF, say using OpenDocFromPath, I want to assign my object to the Tab or Doc or CoreDoc or anywhere where later I can retrieve my object from it.




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

Re: Multi tab: assign custom object to each tab/document

Post by Sasha - Tracker Dev Team »

Hello žarko,

Well, you can store the pointer to the document along with the pointer to your object in some array. I don't think there is a place in the document interface that you can store your private data at.

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

Re: Multi tab: assign custom object to each tab/document

Post by zarkogajic »

Hi Alex,
Well, you can store the pointer to the document...
Yes, that's what I've been (also) trying to do. I just cannot figure out when and how to get the document (I guess you mean IPXV_Document).

I cannot read PXV_Control1.Inst.ActiveDoc just after a call to OpenDocFromPath, as the document might be password protected and fail to load (so ActiveDoc would be an already loaded doc or null).

If I handle e.document.initialized - how do I know the document initialized is "connected" to my object (i.e. the result of my call to OpenDocFromPath) and not for example a result of navigating a link annotation (so target document opens) - a document that is not "connected" to any of my objects.

Also, what is the proper way to get the IPXV_Document when handling e.document.initialized - as at that moment ActiveDoc is not yet changed to the newly loaded doc.

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

Re: Multi tab: assign custom object to each tab/document

Post by Sasha - Tracker Dev Team »

Hello žarko,

You can use the OpenDocFromPath bu using the IPXV_MainFrm method. The IPXV_Control holds the simplified method, and the main frame gives you an IPXV_Document interface as an out parameter. Use the https://sdkhelp.pdf-xchange.com/vi ... iveMainFrm

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

Re: Multi tab: assign custom object to each tab/document

Post by zarkogajic »

That's it! Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Multi tab: assign custom object to each tab/document

Post by Sasha - Tracker Dev Team »

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

Re: Multi tab: assign custom object to each tab/document

Post by zarkogajic »

Ah yes, how about this:
Also, what is the proper way to get the IPXV_Document when handling e.document.initialized - as at that moment ActiveDoc is not yet changed to the newly loaded doc.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Multi tab: assign custom object to each tab/document

Post by Sasha - Tracker Dev Team »

Why do you need that, if you can get the needed document from the OpenDocumentFromPath method? When you get that one, you can link the pointer to the document's pointer and that's all.

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

Re: Multi tab: assign custom object to each tab/document

Post by zarkogajic »

Hi Alex,
Why do you need that...
Because reasons :)

Say a link is clicked in a document I opened by OpenDocumentFromPath - this action will open the target document in a separate tab. I want to handle the e.document.initialized (or any other event?) and get the IPXV_Document of the just opened document.
...store the pointer to the document along with the pointer to your object in some array
Then I will look in the array to see if any of my objects there "match" the just opened document and assign the pointer to IPXV_Document to the matched object.

(I would actually no use the array, but a List<>, but the idea is the same)

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

Re: Multi tab: assign custom object to each tab/document

Post by Sasha - Tracker Dev Team »

Hello žarko,

You can listen to the initialized event and put some mark for the document that it was newly opened. Then listen to the e.document.activated event and check whether the newly opened mark was true, set it to false and do your logic.

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

Re: Multi tab: assign custom object to each tab/document

Post by zarkogajic »

Alex,

But the question still remains: how do I get the corresponding IPXV_Document from any of those events?

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

Re: Multi tab: assign custom object to each tab/document

Post by Sasha - Tracker Dev Team »

Hello žarko,

Code: Select all

PDFXEdit.IPXV_Document vDoc = (PDFXEdit.IPXV_Document)e.pFrom;
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Multi tab: assign custom object to each tab/document

Post by zarkogajic »

Alex,

That's it, thanks.

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

Re: Multi tab: assign custom object to each tab/document

Post by Sasha - Tracker Dev Team »

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

Re: Multi tab: assign custom object to each tab/document

Post by zarkogajic »

Sasha - Tracker Dev Team wrote: Wed Sep 18, 2019 11:29 am

Code: Select all

PDFXEdit.IPXV_Document vDoc = (PDFXEdit.IPXV_Document)e.pFrom;
Alex, it seems I cannot use the same approach in e.activeDocChanged, correct? That is e.pFrom is not IPXV_Document ? What is it?

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

Re: Multi tab: assign custom object to each tab/document  SOLVED

Post by Sasha - Tracker Dev Team »

Hello žarko,

In this event, the pFrom is IPXV_Inst - you can get the Active Document from it at this point.

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