Problems with PDF-XChange 4 Drivers API SDK and Delphi

PDF-XChange Drivers API (only) V4/V5
This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-XChange Printer Drivers SDK (only) - VERSION 4 & 5 - Please use the PDF-Tools SDK Forum for Library DLL assistance.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
mibi16
User
Posts: 6
Joined: Wed Sep 10, 2008 10:40 am

Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by mibi16 »

Dear Support Team,

I have a Problem with the Driver API and Delphi. We migrate from PDFX 2 to PDFX 4 with the need COM-Interface. After modifying my code (from ESC-Sequences to COM) everything seems to work fine with the new Version 4. But now I have problems with printing when creating a lot of PDFs in a bulk job. The pdfsaver just stops and creates no files. After killing the pdfsave4.exe process and restarting my app, some pdfs were generated until it stops again. The exact same routine works since years with the v2 of PDFX.

So I tried to simplify and reproduce this problem in your Sample code. As you can see I modified the methods “FormCreate”, “b_goClick” and “FormDestroy”:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
//  InitSaverObj;
end;


procedure TForm1.b_goClick(Sender: TObject);
begin
  if ed_Dest.Text='' then
    exit;

  InitSaverObj;

  PDFPrinter.SetAsDefaultPrinter;
  IsPXCPrinterDefault:=true;

  PDFPrinter.Option['Save.RunApp']:=cb_RunViewer.checked;
//
  PDFPrinter.Option['Save.File'] := ed_Dest.Text;
  PDFPrinter.Option['Save.SaveType'] := 'Save';
  PDFPrinter.Option['Save.ShowSaveDialog'] := 'No';
  PDFPrinter.Option['Save.WhenExists'] := 'Overwrite';
//
  if cb_Compression.Checked then
  begin
    PDFPrinter.Option['Compression.Graphics'] := 'Yes';
    PDFPrinter.Option['Compression.Text'] := 'Yes';
    PDFPrinter.Option['Compression.ASCII'] := 'No';
    PDFPrinter.Option['Compression.Color.Enabled'] := 'Yes';
    PDFPrinter.Option['Compression.Color.Method'] := 'Auto';
    PDFPrinter.Option['Compression.Indexed.Enabled'] := 'Yes';
    PDFPrinter.Option['Compression.Indexed.Method'] := 'Auto';
    PDFPrinter.Option['Compression.Mono.Enabled'] := 'Yes';
    PDFPrinter.Option['Compression.Mono.Method'] := 'Auto';
  end
  else //cb_Compression.Checked
  begin
    PDFPrinter.Option['Compression.Graphics'] := 'No';
    PDFPrinter.Option['Compression.Text'] := 'No';
  end; //not cb_Compression.Checked
//
  PDFPrinter.Option['Fonts.EmbedAll'] := cb_embFonts.Checked;

  if PageControl1.TabIndex=0 then
  begin
    Printer.Orientation := poLandscape;
      Printer.BeginDoc;
      Printer.Canvas.TextOut(300, 300, ed_textout.Text);
      Printer.NewPage;
      Printer.EndDoc;
  end
  else
  if PageControl1.TabIndex=1 then
  begin
    if FileExists(ed_FileToPrint.Text) then
      ShellExecute(HWND(nil), 'printto', PChar(ed_FileToPrint.Text), PChar('"' + PrinterName + '"'), nil, SW_MINIMIZE);
  end
  else
  if PageControl1.TabIndex=2 then
  begin
    if (WebBrowser1.ReadyState = READYSTATE_COMPLETE) then
          WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER);
  end;

  PDFPrinter.RestoreDefaultPrinter;

  InterfaceDisconnect(PDFPrinter,_IPXCPrinterEvents,FConnectionToken);
  PDFPrinter := nil;
  FEventSink := nil;
end;


procedure TForm1.FormDestroy(Sender: TObject);
begin
//  InterfaceDisconnect(PDFPrinter,_IPXCPrinterEvents,FConnectionToken);
//  PDFPrinter := nil;
//  FEventSink := nil;
end;
With this modification the Printer-Objects are created every time you click the “Go”-Button and set to nil after the job. In your original code you create the Printer-Objects while creating the form and destroy them with the form.

If you now start the Demo with my code and click “Go” sometimes (may be around 10 to 20 times) then the Application freezes and the progress window of the pdfsaver4 stays with this message:


I have choose the “Embedd Fonts” option and I think this problem occurs earlier.

If you do that with your original code everything is ok. It seems that the com object isn’t destroyed correctly.

Because the printing code in my application is inside a DLL which is loaded dynamically I have to instantiate and destroy the printer-objects inside the DLL and so this problem occurs here.

Thanks für your help.

Michael
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3550
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by Ivan - Tracker Software »

Yes, into your code printer is destroyed before printing starts or during printing.

Best practice to destory printer when PDF creation is finished.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
mibi16
User
Posts: 6
Joined: Wed Sep 10, 2008 10:40 am

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by mibi16 »

And when is the PDF creation finished? Destroying in the "DocumentSavedEvent" doesn't work.

Thanks for your help.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3550
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by Ivan - Tracker Software »

I'm afraid deleting object inside its event handler isn't a good idea.

Can you try to post some message to your form from DocumentSavedEvent handler, and into hander of this message destroy IPrinter object?
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
mibi16
User
Posts: 6
Joined: Wed Sep 10, 2008 10:40 am

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by mibi16 »

I'm sorry but printing is encapsulated in all DLL without any visible form or control so there is no message loop to capture messages. This all has worked fine in v2 but PDFs created with PDFX v2 can't be read with Acrobat Reader 9. Are there any other ideas? Thanks.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3550
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by Ivan - Tracker Software »

Can you use TEvent?
Into main function you need to wait for this event before call PDFPrinter.RestoreDefaultPrinter;

Into event handler, for example DocumentSavedEvent, you will need to trigger this TEvent.

P.S. Instead of using DocumentSavedEvent you can use DocumentSpooled event.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
Tom - Tracker

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by Tom - Tracker »

Please see attached file in connection with the above :D
Attachments
FixedProject1.zip
(3.32 KiB) Downloaded 207 times
mibi16
User
Posts: 6
Joined: Wed Sep 10, 2008 10:40 am

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by mibi16 »

1st "Go"-Click: Works wonderful
2nd "Go"-Click: Works wonderful
3rd "Go"-Click: Works wonderful
4th "Go"-Click: Dialog with "Optimizing" hangs and virtual Printer-Driver was not destroyed... :?
Tom - Tracker

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by Tom - Tracker »

Will need to look into number (4) :shock:
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by Corwin - Tracker Sup »

Please let us know the exact version of your OS.
mibi16
User
Posts: 6
Joined: Wed Sep 10, 2008 10:40 am

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by mibi16 »

Win XP SP3 (5.1.2600) - German
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3550
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by Ivan - Tracker Software »

Please let me know the values of items "EnableTimeout" and "Flags" of the registry which are located under the path:
HKEY_CURRENT_USER\Software\Tracker Software\PDF-XChange 4.0\Drivers\pdfSaver
and
HKEY_LOCAL_MACHINE\Software\Tracker Software\PDF-XChange 4.0\Drivers\pdfSaver
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
mibi16
User
Posts: 6
Joined: Wed Sep 10, 2008 10:40 am

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by mibi16 »

HKEY_CURRENT_USER\Software\Tracker Software\PDF-XChange 4.0\Drivers\pdfSaver
EnableTimeout : 1
Flags : 0

HKEY_LOCAL_MACHINE\Software\Tracker Software\PDF-XChange 4.0\Drivers\pdfSaver
EnableTimeout : 1
Flags : nonexistent
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3550
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by Ivan - Tracker Software »

Please set both EnableTimeout to 0 (zero) and check if the trouble still exist (you will need to kill pdfSaver4.exe process before changing registry values).
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
Stemonte
User
Posts: 41
Joined: Mon Nov 26, 2007 9:17 am

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by Stemonte »

Hi,
I have the same problems with Delphi (2009);
After the first time, the SDK hang-up and restart after several seconds.....but at last it crash with "RPC error";
I have execute your fixed project, but without benefit...
Please, what I can do for print correctly several document? I am happy also if you fixed project works!
Thanks in advance,
Stefano Monterisi
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom
Contact:

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by John - Tracker Supp »

Hi,

Please post a sample - simple - project which displays the issue and provide any specail info on use - along with the info on what Windows OS we need to test in to reproduce, please provide both project code and an '.exe, supporting Dll's' etc ready to run ..

All should be zipped and we will take a look, also please ensure you are using the latest release.

Finally - please ensure no license info if you are licensed is embedded in the project.

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
Stemonte
User
Posts: 41
Joined: Mon Nov 26, 2007 9:17 am

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by Stemonte »

Hi,
I have found a rapid solution because I must send urgently my application to customer: I Kill the PdfSaver4.exe process from code every time I finish to convert one document; But I think this is'nt the right way :-)

Good Job,
Stefano Monterisi
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom
Contact:

Re: Problems with PDF-XChange 4 Drivers API SDK and Delphi

Post by John - Tracker Supp »

Understood - well when you get a minute we would be pleased to investigate further once we have your project.

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
Post Reply