PDF-XChange / Multithreaded COM

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-XChange Printer Drivers SDK (only) - Please use the PDF-Tools SDK Forum for Library DLL assistance.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software, Andrew - Tracker Support, Tracker - Clarion Support, John - Tracker Supp, Support Staff, moderators

Post Reply
DISystemer
User
Posts: 29
Joined: Fri Feb 18, 2005 2:23 pm
Location: Trondheim, Norway
Contact:

PDF-XChange / Multithreaded COM

Post by DISystemer » Fri Jan 12, 2007 10:23 am

Several of our applications use PDF-XChange. We have implemented the communication with PDF-XChange in a DLL and tried using both message-based communication and the CPXCControl, and it all has been working well.

However, one our applications now need to use multithreaded COM, and then the communication with PDF-XChange doesn't work as it should anymore.

We have written a small test application that use automation to open a Word document and print it to PDF-XChange. When we use "CoInitialize()" to initialize COM it works well, but when we call "CoInitializeEx(nil, COINIT_MULTITHREADED) it fails.

Debugging shows that with multithreaded COM, the OnPrintingStarted event of the CPXCControl is never called, and if we use message-based communication the application never gets the pdfxcMsg_StartDoc message.

Hope you can help us with this problem.

Regards,
Arnstein

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Fri Jan 12, 2007 10:32 am

Hi,

Could you please provide us with the sample application you have created and any supporting additional files/instructions we may require to run and test here - please provide both compiled exe's' & dll's etc and source code for the project to allow us to modify if required.

Please zip any files uploaded - or emailed directly to us (usrfiles@tracker-software.com) also if posting here - please ensure your license codes are not included for general viewing.

Also please briefly outline the environment/system this is to be run on and Windows OS's in use.

thanks.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

DISystemer
User
Posts: 29
Joined: Fri Feb 18, 2005 2:23 pm
Location: Trondheim, Norway
Contact:

PDF-XChange / Multithreaded COM

Post by DISystemer » Fri Jan 12, 2007 12:20 pm

Please find attached a Delphi test project.
The program opens a document in Microsoft Word and prints it to PDF. It uses a DLL to do the actual communication with PDF-XChange. Please let me know if you need the source code for the DLL too.

Thanks,
Arnstein
Attachments
DIPrintTest.zip
Delphi test project + DIPDF.DLL
(281.74 KiB) Downloaded 129 times

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Fri Jan 12, 2007 4:08 pm

Hi,

Please do provide the source code for the DLL too - in the meantime I will ask our in-house Delphi Project dev to take a look at the project provided to date.

thanks.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

DISystemer
User
Posts: 29
Joined: Fri Feb 18, 2005 2:23 pm
Location: Trondheim, Norway
Contact:

Post by DISystemer » Sat Jan 13, 2007 11:17 am

Tracker Support wrote:Hi,

Please do provide the source code for the DLL too - in the meantime I will ask our in-house Delphi Project dev to take a look at the project provided to date.

thanks.
Will do, but since this is part of our commercial products I would prefer to send it directly to you rather than posting it in this forum. Is that possible?

Thanks,
Arnstein

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Sat Jan 13, 2007 11:23 am

Hi Arnstein,

Sure - please send direct to johnv@tracker-software.com - please do zip.

thanks.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Mon Jan 15, 2007 10:37 am

Hi Arnstein,

Our project manager has now looked at this and advises that when using the ActiveX you should not use

CoInitializeEx(nil, COINIT_MULTITHREADED)

but should use

CoInitializeEx(nil, COINIT_APARTMENTTHREADED)

Unfortunately we could not rebuild and test your DLL as we are missing some project files - the first of which is ConfirmPasswordDialog.pas and most likely others ?

I hope the above helps.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

DISystemer
User
Posts: 29
Joined: Fri Feb 18, 2005 2:23 pm
Location: Trondheim, Norway
Contact:

Post by DISystemer » Wed Jan 17, 2007 9:17 am

I'm sending the missing files (ConfirmPasswordDialog) to you by email.

We have tried using apartment threading, and the communication with PDF-XChanage works well under this threading model. Unfortunately, the rest of our application doesn't, it demands multithreading.

What can we do to fix this? I suppose we could make a separate .exe to handle printing, but this means a lot of work for us as our application prints both using Microsoft Word and QuickReport (which gets data from various data sources).

Thanks,
Arnstein

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Wed Jan 17, 2007 9:22 am

Thanks Arnstein,

Unfortunately the received zip file when saved to disk here was corrupt - could you please re-send and as soon as received, will ask our Project Dev for Delphi to look into and advise.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

DISystemer
User
Posts: 29
Joined: Fri Feb 18, 2005 2:23 pm
Location: Trondheim, Norway
Contact:

Post by DISystemer » Mon Jan 22, 2007 12:48 pm

I have now made a simpler Delphi test project. It contains one form, and on this form I place a TCPXCControl (the PDF-XChange ActiveX control).

In the initialization code I initialize COM multithreaded:
"CoInitializeEx(nil, COINIT_MULTITHREADED);"

During startup, when the program tries to create the main form (the form with the ActiveX-control) the program fails with the following exception:
"EOleError: Could not obtain OLE control window handle". This occurs in the TOleControl.HookControlWndProc method in unit OleCtrls, which is part of Delphi VCL, and the program terminates.

The statement that fails is this: "FOleInPlaceObject.GetWindow(WndHandle)". It returns WndHandle=0, and this triggers an exception in the next statement.

In other words: The program fails before any of our printing code is executed, the only code that I have written in this test project is the call to CoInitialize.

If I change COM initialization to singlethreaded the program works fine, but as I said earlier we have to run our program multithreaded for other reasons so this is not an option.

At the moment, I'm not able to see what we can do to avoid this. Any help would be greatly appreciated.

My development machine runs Windows XP SP2 and I use Delphi 7.

Thanks,
Arnstein

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Mon Jan 22, 2007 6:47 pm

Hi Arnstein,

Later this month we will change the ActiveX from being a DLL to an Exe and we believe this will resolve this issue - we do not think there is any other way to satisfy your need without causing other issues.

Thanks for your patience.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

DISystemer
User
Posts: 29
Joined: Fri Feb 18, 2005 2:23 pm
Location: Trondheim, Norway
Contact:

Post by DISystemer » Wed Feb 21, 2007 12:48 pm

Where can we get the .exe version of the ActiveX control? We would like to test it as soon as it's available.

Thanks,
Arnstein

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Wed Feb 21, 2007 5:18 pm

Hi,

I am afraid it is not yet available as we are altering the JPEG2000 decoding encoding to resolve some important Viewing issues - until this is complete the ActiveX will not be released.

Thanks for your patience.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

Post Reply