How to Instantiate  SOLVED

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.
jeffp
User
Posts: 924
Joined: Wed Sep 30, 2009 6:53 pm

How to Instantiate

Post by jeffp »

I'm using Delphi and I want to instantiate by calling the DLL directly.

I've translated this

typedef HRESULT (__cdecl *t_pPXV_GetInstance)(IPXV_Inst** ppInst);

into this

type
TGetInstancePXV = function(var ppInst: IPXV_Inst): HRESULT; stdcall;

And it seems to work fine (but would like to confirm this is correct in Delphi).

The Help says I can't do this if I want to use IPXV_Control. I'd prefer not to have to register the DLL in the normal COM way. So is there a way to still use IPXV_Inst and then place this on a form to be seen by the user as the full Editor control? I'm not quite sure I understand the difference between IPXV_Control and IPXV_Inst.

Also, I'm using the PDFXEditCore.x86.dll in my application and was wondering why there isn't a "PXC_GetInstance" in that DLL in addition to the "PXV_GetInstance". I don't what to have to use both PDFXEditCore.x86.dll and PDFXCoreAPI.x86.dll.

The reason I ask is that in my application I will be embedding the PDF Editor as a visual control and allow user interaction, but I also allow a lot of PDF file manipulations in a non-visual manner by allow a user to select a file from a file list and just load PDFs directly from the file system without the need of the visual editor. Not quite sure what combination of objects I should be working with in this context. It seems that the new Editor SDK wants be to only have one instance of PXV_Inst. I know I can get the PXC_Inst from the PXV_Inst, but all my file manipulations only need PXC_Inst and I don't want any of these files appearing in the visual editor.

And, I believe I read that PXC_Inst is multi-threaded whereas PXV_Inst is not. So ideally, I'd like to get one visual instance of PXV_Inst in my application along with multiple non-visual instances of PXC_Inst. Is this possible?

I'm coming from the ViewerAX SDK and Pro DLL SDK so any guidance here would be helpful.

You guys have always been great and your product is exceptional, so I don't want to come across as a pain by all my recent Delphi posts. I just need some upfront direction and then I'll be on my way and out of your hair again. Thanks.

--Jeff
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How to Instantiate

Post by Sasha - PDF-XChange »

Hello Jeff,

I've updated the ActiveX Objects description, please read it:
https://sdkhelp.pdf-xchange.com/vie ... How_to_Use

HTH,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 924
Joined: Wed Sep 30, 2009 6:53 pm

Re: How to Instantiate

Post by jeffp »

I appreciate your expanded explanation of the ActiveX controls. It better clarifies how to get instances of the various objects, but it is still not totally clear on how to address the need for multiple instances of these objects. So let me try to better explain.

Let's take a quick step back. Please keep in mind that I, and perhaps many others out there, are coming from your ViewerX SDK and Pro SDK and are now trying to accomplish the same sorts of things with the new Editor SDK. I my case I was using the ViewerX SDK for some tasks and the Pro DLL SDKS for other tasks, all within the same running program.

Specifically, my program currently uses two visual instances of the ViewerAX control, one that acts as a full viewer like your end user Viewer and the other used to just "preview" PDF files as the user clicks on a file name from a list of files. Again, two separate instances of the ViewerAX in the same running program, just under two different Ribbon Tabs in my main program. In addition, I use the Pro SDK to provide a set of PDF manipulation tools for my program. These tools just call the PRO DLLs directly to quickly delete pages, combine PDFs, etc., but in a non-visual manner. That is, they don't go through any of the ViewerAX controls above.

That having been said, I'm trying to grasp how I need to change things with the new Editor SDK interfaces. I fully understand that if I use the IPXV_Control I can in turn get IPXC_Inst from IPXV_Control and IPXC_Inst from IPXV_Inst using GetExtension. But I still need clarification on the items below.

Am I correct in saying I can only have one instance of TPXV_Control in my application now? As explained above, I really need two, one as the end user Editior and one as a file previewer. Is there any way to accomplish this?

If I can only use one instance of TPXV_Control, and I in turn get the IPXC_Inst from TPXV_Control for use in my PDF tools as described above, will opening files with IPXC_Inst that I got from TPXV_Control cause those files to appear in the TPXV_Control UI? Again, all my non-visual PDF manipulation procedures should not affect any files I have loaded in the TPXV_Control but I'm not sure if that will be the case if my IPXC_Inst is derived from TPXV_Control.

Lastly, what if I run two separate threads inside my program (for the purpose of generating thumbnail images of PDF files), how can I get the use of the IPXC_Inst in those threads in order to do the tasks I need. Do these still need to be the IPXC_Inst that come from TPXV_Control or can I create two additional separate instances of IPXC_Inst in each of these threads. This is why I asked earlier about perhaps having the need for a "PXC_GetInstance" call in PDFXEditCore.x86.dll.

Again, sorry to be so dense here, but I hope if you step back and consider where I (and others perhaps) are coming from with the old Viewer and Pro SDKs, some of our confusion will make better sense to you.

--Jeff
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How to Instantiate

Post by Sasha - PDF-XChange »

Hello Jeff,

You can add two or more Editor ActiveX COM components on your form - that would not be the problem. They will use the same IPXV_Inst and other instances. Meaning that the IPXV_Inst from the Control1 will be the same as the IPXV_Inst from the Control2 (which is also correct for the IPXC_Inst and other). But you can manage the controls differently thus achieving what you need.

You won't need the Pro DLL SDKS for other tasks because the Editor SDK itself handles all of the things needed. The operations can be used to quickly delete pages, combine PDFs, etc. They are majorly documented and some of them have full fledged samples so it won't be a problem of using them.

As for you question about threads, the optimal way would be if you can pass the IPXC_Inst that you got from the IPXV_Inst to the working thread as a parameter (or have access to it as a global member) and then you can do what you need. You don't need to create it - just pass it from above and use it - it will be the same for both of the controls.

Maybe I missed something - do ask.

Here's the link to the small delphi sample that will get you started:
https://github.com/tracker-software/PDFEditSDK-Delphi

HTH,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 924
Joined: Wed Sep 30, 2009 6:53 pm

Re: How to Instantiate

Post by jeffp »

Perfect. This was the exact clarification that I needed.

But it looks like if I want to user IPXV_Control I have to register the DLL via the traditional COM method and can't use "PXV_GetInstance" where I call the DLL directly. I was hoping to call the DLL directly since on occasions we have users that also have other products of yours on their machines that are registering the same PDFXEditCore.x86.dll that we distribute, and sometimes they aren't on the same version. Was hoping to avoid this.

One thought, what would happen if I first got IPXV_Inst from a direct call of "PXV_GetInstance" to PDFXEditCore.x86.dll and then I placed my Editor control on the form using TPXV_Control. Is that wrong? Would TPXV_Control be using the prior instance of IPXV_Inst or would it try to create a new one which sounds like is not possible?

Lastly, thanks for the sample code. It was very helpful in learning how to setup the IOperations. However, IOperations seem to work only with IPXV_Inst. Shouldn't I be constructing my PDF manipulation procedures that I will possibly use inside of Threads from the IPXC_Inst instead? Or am I able to pass IPXV_Inst as a parameter in creating my Threads just as you mentioned to do with IPXC_Inst above?

--Jeff
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How to Instantiate

Post by Sasha - PDF-XChange »

Hello Jeff,

Judging from what you need, maybe it's better to use the manifest as described here:
https://sdkhelp.pdf-xchange.com/vie ... stribution
We've updated the Delphi sample to work with the manifest:
https://github.com/tracker-software/PDFEditSDK-Delphi

As for the IPXV_Inst - sadly, but it is thread unsafe. So all of the operations should be done from the main thread for the correct work of the Control. Although, you can use the IPXC_Inst - it is thread safe.

HTH,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 924
Joined: Wed Sep 30, 2009 6:53 pm

Re: How to Instantiate

Post by jeffp »

You mentioned above that I can add two or more Editor ActiveX COM components to my application but they share the same IPXV_Inst. I've been playing around with this and I don't think it's going to work. When I changes things in one control they seem to affect the other control. And the document count is aggregated across both controls.

This is really a limitation for me. I read in another post that you are considering changing this so that multiple instances are allowed. Again, I'm coming from the ViewerAX where multiple instances of that control are allowed and nothing is shared among the controls.

Are there any plans to make IPXV_Control/IPXV_Inst work like the old ViewerAX as it relates to multiple instances in the same running application? I hope so because I'm kind of stuck now.

--Jeff
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2500
Joined: Thu Jun 30, 2005 4:11 pm

Re: How to Instantiate

Post by Vasyl - PDF-XChange »

Hi, Jeff.
Are there any plans to make IPXV_Control/IPXV_Inst work like the old ViewerAX as it relates to multiple instances in the same running application?
As usual, migrating from using one SDK to using other SDK - this process cannot be too easy. The Editor SDK is completely different than Viewer SDK. It is not just upgrade from old to new version of the same SDK.

Theoretically, we can try to solve this problem by adding support of multiple instances (it may solve other related problems with using SDK in multithreaded app).
But it is too difficult task for now, so I can't promise for 100% that it will be done and done quickly.

Best
Regards.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
jeffp
User
Posts: 924
Joined: Wed Sep 30, 2009 6:53 pm

Re: How to Instantiate

Post by jeffp »

Vasyl,

I understand that the new SDK is much different and better, so I'm not meaning to complain here. I'm just looking to add the new SDK into my existing program while preserving my current functionality with respect to what we do with PDFs.

Perhaps you can give me a bit of guidance on what objects to use currently. Here's what I'm doing in my application.

1. On one Ribbion Tab in my app, an instance of ViewerAx is embedded on formA and acts as a full PDF Editor for the user.
2. On a different Ribbon Tab in my app, instance of ViewerAx is embedded on formB and acts as a preview window for PDF files.
3. I use the Pro SDK dll calls to manipulate specific PDF files on the file system via drop down menu option in my app (these sometimes are called in threads).

It seems with the new Editor SDK I can only create one object which is IPXV_Control and then derive IPXV_Inst and IPXC_Inst from it. But 1 and 2 above really need their own independent controls. And in 3, it would be nice to have independent instance of IPXC_Inst.

Is it possible to accomplish the above with the new Editor SDK? If so, how do you suggest that I use your new objects?

Thanks again.

--Jeff
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2500
Joined: Thu Jun 30, 2005 4:11 pm

Re: How to Instantiate

Post by Vasyl - PDF-XChange »

2. On a different Ribbon Tab in my app, instance of ViewerAx is embedded on formB and acts as a preview window for PDF files.
Just for preview you may use our other feature:

Code: Select all

CComPtr<IUnknown> unk;
IPXV_Inst::GetExtension("UIX", &unk);

CComPtr<IUIX_Inst> uiInst;
unk->QI(&uiInst);

UIX_CreateObjParams cop = { 0 };
cop.hWndParent = yourFormContainer.HWND;
cop.nStdClass = UIX_StdClass_Blank;
cop.nCreateFlags = UIX_CreateObj_Windowed;
cop.nWndStyle = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
cop.rc = yourFormContainer.ClientRect;

CComPtr<IUIX_Obj> tmpContainer;
uiInst->CreateObj(&cop, &tmpContainer);

CComPtr<IPXV_PagesPreviewCtl> pCtl;
IPXV_Inst::CreatePagesPreviewCtl(tmpContainer, &cop.rc, "preview", 0, 0, false, &pCtl); // PXV_PagesPreviewStyleFlags

pCtl->put_Doc(docForPreview);

// pCtl->Layout.put_CurrentPage(99);
// pCtl->Layout.SetZoom(PXV_ZoomMode_FitPage, 100.0);
- docForPreview - it must be previously opened by you, even in other thread - not problem with that.

IPXV_Control - you may create more than one such objects BUT all must be created in one thread and all of them will be linked with the same one IPXV_Inst global object.
Only one strong requirement we have currently - whole Editor's UI must be instantiated, used and finalized in the same thread. But you still able to use all functionality of IPXC_Inst/IPXS_Inst/IAUX_Inst levels (and deeper) from any thread.

HTH
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
jeffp
User
Posts: 924
Joined: Wed Sep 30, 2009 6:53 pm

Re: How to Instantiate

Post by jeffp »

For my file preview control, I really need the full editor as well. The only difference is that I need that one to be in "Single Document mode" and the editor to be in multi-document mode. And the toolbars for each would be different.

Is it possible to do that if I have two IPXV_Control objects sharing the same IPXV_Inst? Relatedly, I'd need to export and import different settings files for each IPXV_Control. But this doesn't look possible, or is it?

--Jeff
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How to Instantiate

Post by Sasha - PDF-XChange »

Hello Jeff,

This needs an investigation from our side. When we'll have the results, we'll post them here.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 924
Joined: Wed Sep 30, 2009 6:53 pm

Re: How to Instantiate

Post by jeffp »

I'm creating a comprehensive Delphi Demo project that contains this and other issues I've been posting about. Would it help if I sent it to you?

--Jeff
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How to Instantiate

Post by Sasha - PDF-XChange »

Hello Jeff,

Of course it will - we can even add it to the our GIT sdk sample block =)
Though about this problem - I'll test it on Monday and will see how two controls behave when changing their properties.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How to Instantiate

Post by Sasha - PDF-XChange »

Hello Jeff,

I've managed to do some manipulations with the two controls on form so that they would look like what you need. Here's the code sample for that:
https://gist.github.com/Polaringu/3c61c8b49f2612fec26f

The thing is that the independent part starts from the IPXV_MainFrame and basically that's what the each control should be viewed like, when you want to look at them independently. Meaning that you can manipulate them (IPXV_MainFrame, IPXV_MainView) to customize the available toolbars, commands etc.

I'll try to improve this sample based on the problems that you would encounter when trying to implement the same behavior that you had with the old SDK.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 924
Joined: Wed Sep 30, 2009 6:53 pm

Re: How to Instantiate

Post by jeffp »

I've just switched over to the version 6 build of the Editor Core DLL and have got a new key, but I'm getting watermarks on everything.

Can you take a look at the attached demo project and see if you can recreate the Watermarks on your end.

I've tried reinstalling a couple of times and can't think of anything else to do.

Thanks.

--Jeff
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How to Instantiate

Post by Sasha - PDF-XChange »

Hello Jeff,

Please do NOT post your license information on the forums, or we will be forced to deactivate it!

If you need to send it - do it via mail.
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How to Instantiate

Post by Sasha - PDF-XChange »

Ok, as far as I see, you have a PRO SDK key meaning that you don't have the access to the Editor SDK, based on this description:
https://www.pdf-xchange.com/product ... ge-pro-sdk
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19961
Joined: Mon Jan 12, 2009 8:07 am

Re: How to Instantiate

Post by Stefan - PDF-XChange »

Hello Jeff,

If you need to get access to the Editor SDK - please contact us at [email protected] and we wil work out with you the possible upgrade options.

Regards,
Stefan
jeffp
User
Posts: 924
Joined: Wed Sep 30, 2009 6:53 pm

Re: How to Instantiate

Post by jeffp »

My bad on the license key thing. I won't make that mistake again.

I do have a license to the Editor SDK and that is the key that was in my account and assigned to me by Chris. Feel free to check with Chris to confirm I've paid for the Editor SDK.

--Jeff
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19961
Joined: Mon Jan 12, 2009 8:07 am

Re: How to Instantiate

Post by Stefan - PDF-XChange »

Hi Jeff,

Yes confirmed - and provided the key to Sasha as well.
Please make sure you use the correct Editor key - the one starting with xUL... (as it seems like the sample project Sasha removed had the PRO SDK one inside), and all should be well.

Regards,
Stefan
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How to Instantiate

Post by Sasha - PDF-XChange »

Hello Jeff,

Just checked the key that Stefan provided me with - everything's working fine.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 924
Joined: Wed Sep 30, 2009 6:53 pm

Re: How to Instantiate

Post by jeffp »

Did you run my sample program with that key?

For example, when I launch the demo program, I go to the first tab and press the "Load Editor" button. When the Editor loads, I then go the File>>Open and open a PDF file. When it loads, it has watermarks on it.

Are you saying that doesn't happen on your end? That would be very strange.

--Jeff
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How to Instantiate

Post by Sasha - PDF-XChange »

I've initialized the control with your key in the FullDemo sample - it behaved like the correct key (I'm talking about the other key that Stefan mentioned).

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 924
Joined: Wed Sep 30, 2009 6:53 pm

Re: How to Instantiate

Post by jeffp »

Can you try my demo code that I uploaded yesterday?
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How to Instantiate

Post by Sasha - PDF-XChange »

Hello Jeff,

Just tried your other key in place of the old one in your demo - no labels were added. Maybe you just open files with saved labels?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 924
Joined: Wed Sep 30, 2009 6:53 pm

Re: How to Instantiate

Post by jeffp »

What other key are we talking about? I mistakenly sent my real key when I uploaded my demo project. It sounds like that one wad removed. But is that the key you tested? That's the only key I have. Just confirming that we are using the same key here.

If so, I've going to need to try this on a different machine.

...

Just tried on a different computer. Same result. I get watermarks when I open a clean PDF.

--Jeff
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19961
Joined: Mon Jan 12, 2009 8:07 am

Re: How to Instantiate

Post by Stefan - PDF-XChange »

Hi Jeff,

You have an account in our system. If you log in with that - you should be able to see both your keys. One will be for the Pro SDK, and the other one for the Editor SDK. I can't provide the account info or the keys here, so please do contact our [email protected] or [email protected] e-mail if you need to recover access to your account and license keys.

Cheers,
Stefan
jeffp
User
Posts: 924
Joined: Wed Sep 30, 2009 6:53 pm

Re: How to Instantiate

Post by jeffp »

I follow you. I did log into my account and I am using the Editor SDK key assigned to me in my account. It was the same key that I mistakenly included in my demo project I wanted you to take a look at.

With this key I'm getting watermarks. I tried it on two machines.

What I'm asking is if you can run my demo project with the key assigned to my Editor SDK and see if you get watermarks or not. If you don't can' you email me directly the key that you are using just to double check on my end.

But again, I am using what appears to be the key assigned to my Editor SDK account item.

Thanks again.

--Jeff
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19961
Joined: Mon Jan 12, 2009 8:07 am

Re: How to Instantiate

Post by Stefan - PDF-XChange »

Hi Jeff,

It's 23:03 over here, so I can't try right now :)
But Sasha could not reproduce the issue with our Full Demo project and your license key.
Can you test the full demo at your end? If it works - then we will know the key is correct and the issue will need to be found in the way it is actually supplied through code.

Cheers,
Stefan
jeffp
User
Posts: 924
Joined: Wed Sep 30, 2009 6:53 pm

Re: How to Instantiate

Post by jeffp »

Stefan,

I'm really not trying to be a pain here, but one of my issues is that I've never been able to get your ActiveX control imported into the Delphi ActiveX palette so that it can be dropped on the TForm. No big deal because I, like many Delphi developers, prefer to create my controls at runtime.

As such, I'm creating the control from code at runtime and then assigning the TForm (or another TPanel) as the control's Parent. Again, I create all my AciveX controls this way. Not sure if this is part of the license key issue or not.

In any event, I'm attaching the most simple demo project I could create to illustrate this issue. The main form has a Load button which will create the TPXV_Control and assign its Parent to the form. The control then appears on the form with the editor's menus. I then click the File>>Open menu and open any PDF file. They all then display in the editor with watermarks.

I remembered not to include my key in this project (sorry about that mistake the last time), so you'll have to paste it in yourself and recompile the project to test.

Thanks again.

--Jeff
You do not have the required permissions to view the files attached to this post.
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How to Instantiate

Post by Sasha - PDF-XChange »

Hello Jeff,

Mailed you a screenshot that everything works (Email name is How to Instantiate).

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19961
Joined: Mon Jan 12, 2009 8:07 am

Re: How to Instantiate

Post by Stefan - PDF-XChange »

Hi Jeff,

Just e-mailed you the correct license key that you should be using with the Editor SDK, hopefully that will solve the issue!

Regards,
Stefan
jeffp
User
Posts: 924
Joined: Wed Sep 30, 2009 6:53 pm

Re: How to Instantiate

Post by jeffp »

Product key issue solved.

Thanks for your patience on this one.

--Jeff
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19961
Joined: Mon Jan 12, 2009 8:07 am

Re: How to Instantiate

Post by Stefan - PDF-XChange »

:)