Print Page | Close Window

QuckPDF in a thread

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2881
Printed Date: 13 May 24 at 12:38PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: QuckPDF in a thread
Posted By: Chopinke
Subject: QuckPDF in a thread
Date Posted: 29 Apr 14 at 6:07PM
Hi,

I am evaluating QuckPDF library with Delphi7. I am using threads.


constructor TMyThread.Create(CreateSuspended: Boolean);
begin
  inherited Create(CreateSuspended);
  Priority := tpNormal;
  FreeOnTerminate := false;
//  CoInitialize(nil);
  DPL := TDebenuPDFLibrary1014.Create;
  DPL.UnlockKey('blabla');
end;

destructor TMyThread.Destroy;
begin
  DPL.Free;
  DPL := nil;
//  CoUnInitialize;
  inherited Destroy;
end;

procedure TMyThread.Execute;
begin
while not Terminated do
  if not Suspended then
  begin
      PDFDocument := DPL.NewDocument;
  end;
end;

I am getting 'CoInitialize has not been called' exception at the NewDocument() call, even if I uncomment the CoInitilalize in the code above.

What the problem may be?

Thanks!



Replies:
Posted By: tfrost
Date Posted: 30 Apr 14 at 10:19AM
Have you tried CoInitializeEx?


Posted By: Chopinke
Date Posted: 30 Apr 14 at 10:24AM
I changed my solution that I do the .create and .free inside the thread running. I am not sure why would I even have to call CoInitialize, because

1) They already fixed that issue in much earlier version
2) They claim free of Adobe Reader, so why do they need any OLE stuff?

But I will try the CoInitializeEx() and let you know the result.


Posted By: tfrost
Date Posted: 30 Apr 14 at 12:16PM
Which type of the Debenu library are you using (static Delphi, DLL, ActiveX)?


Posted By: Chopinke
Date Posted: 05 May 14 at 11:21AM
Sorry for the late reply, I was out of town. Currently Delphi 7, and will also try with Delphi XE4 (or XE5)


Posted By: Chopinke
Date Posted: 12 May 14 at 9:01PM
I checked the CoInitializeEx and getting RPC_E_CHANGED_MODE for COINIT_MULTITHREADED.
If I use COINIT_APARTMENTTHREADED, then I get S_FALSE back, meaning that the COM library is already initialized.

I believe I move on now for always DPL.Create ... DPL.Free, for each execution of the tread, and will check later how is it behaving in XE4 or later.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk