Page 1 of 1

Events not firing

Posted: Mon Jun 27, 2016 10:26 pm
by andrewb
I have downloaded and installed the Drivers API (6.0.317.1) onto a Windows 2012 Server. I have opened the C# example in Visual Studio 2015 and can successfully run the code to create a PDF from a text file. However I cannot get any of the events (e.g. OnFileSaved) to fire. They do not log to the form and do not get hit if I put a breakpoint on them.

I have created my own code using the API to create PDF documents from word documents. There are 2 scenarios:
1. Create a single PDF
2. Create a merged PDF from multiple word documents

For the both scenarios I am getting inconsistent results. It appears certain documents are skipped if I create multiple single PDFs in quick succession. When I use the merge method only some of the documents are added. It appears that the code is not waiting for the first print event to finish before moving to the next. I have tried adding a wait event for the printjob ( printJob.WaitForExit();) but this causes the code to take a long time to complete. I have also experimented with using a loop with a sleep event checking of the file has been created.

I would like to use the OnFileSaved event to mitigate this issue but I cannot work out how to get it to fire. Is there some trick to getting these events working in C#?

Re: Events not firing

Posted: Fri Jul 01, 2016 11:43 am
by Tracker Supp-Stefan
Hello andrewb,

I spoke with a colleague working on the Drivers API, and he said that we will check the sample projects - and see why the events are not firing properly in the samples.

In the mean time he also recommended that you can try to use
PDFPrinter.WaitForPrintEvent(event_DocumentSaved)
And wait while the printer finishes generating the PDF File.

Regards,
Stefan

Re: Events not firing

Posted: Fri Jul 01, 2016 12:06 pm
by andrewb
Thanks Stefan. I'm not sure how to use the waitforprintevent method. I tried passing in the name of the event but it won't compile.

Re: Events not firing

Posted: Fri Jul 01, 2016 3:14 pm
by Ivan - Tracker Software
I guess it does not compile because you have to use namespace for the enum value:

Code: Select all

PDFPrinter.WaitForPrintEvent(PXCComLib6.event_DocumentSaved)
HTH

Re: Events not firing

Posted: Sun Jul 03, 2016 11:53 pm
by andrewb
Hi Ivan

I implemented the WaitForPrintEvent however it throws an error - see attached.

Looking at your documentation (PDF-XChange Drivers API SDK 2012 User Manual) it appears this event is unsupported and will return "an E_NOTIMPL error code:" (see attached)

Re: Events not firing

Posted: Wed Jul 06, 2016 2:02 pm
by Ivan - Tracker Software
Unfortunately documentation for this function in not up to date. Actually this method is implemented, and when you call it waits for specified printer event (first method's parameter) for maximum of specified time (second method's parameter, in milliseconds).

If the required event will happen during specified period of time, function will be terminated and will return S_OK.
If the required event will not happen - function will return E_ABORT error code.

It is the situation you got - you specified 1000 milliseconds to wait for event_DocumentSaved, but it didn't happen in that period of time and you got E_ABORT returned from the function.

Re: Events not firing

Posted: Wed Jul 06, 2016 2:05 pm
by Roman - Tracker Supp
Hello andrewb,

The issue with events has been fixed and will be available in the next release.

In your case WaitForPrintEvent() fails due to used timeout (1 second). I agree the reported error is obscure, it will be more specific in the next release.

Re: Events not firing

Posted: Wed Jul 06, 2016 10:50 pm
by andrewb
I have updated the timeout to 30000 milliseconds. It doesn't seem to matter how long I use as a timeout, i still get the E_ABORT error.

As you can see from attached screenshot, when I use WaitForPrintEvent a new window appears "Printing Progress" that sits at 0% done and doesn't change.

Re: Events not firing

Posted: Thu Jul 07, 2016 11:32 am
by Roman - Tracker Supp
Andrew, try the attached fix.
Unzip the file to an empty directory and run Fix.cmd as Administrator.

Revert the C# demo source to its original state.

Re: Events not firing

Posted: Thu Jul 07, 2016 10:31 pm
by andrewb
Hi Roman, I have applied the supplied fix but no change, still get the "Printing Progress" window stuck at 0%

Re: Events not firing

Posted: Fri Jul 08, 2016 2:43 am
by Roman - Tracker Supp
Did you try the unmodified C# demo ("%ProgramFiles%\Tracker Software\PDF-XChange 6 API\Examples\Bin\C#\PDFdriverAPI.exe" )?
Please check if pdfSaver6.exe has been updated ("%ProgramFiles%\Tracker Software\PDF-XChange 6 API\pdfSaver6.exe" must have file version 6.0.317.2).

Re: Events not firing

Posted: Fri Jul 08, 2016 2:47 am
by andrewb
Yes, I used the C# example provided with API

I am using a VM running Windows Server 2012 - could this be an issue?

Re: Events not firing

Posted: Fri Jul 08, 2016 3:07 am
by Roman - Tracker Supp
Can I have a remote debug session on your machine (see the details here)?
I mean your VM.

Re: Events not firing

Posted: Fri Jul 08, 2016 3:22 am
by andrewb
Yes you can, how do I send my details?

Re: Events not firing

Posted: Fri Jul 08, 2016 3:32 am
by Roman - Tracker Supp
Please e-mail it to me (press "EMAIL" button below my post).

Re: Events not firing

Posted: Fri Jul 08, 2016 3:41 am
by andrewb
Sorry Roman but I don't see an "Email" button, just a "Profile" button

Re: Events not firing

Posted: Fri Jul 08, 2016 3:56 am
by Roman - Tracker Supp
Sorry - it seems I can see it due to my admin privileges on the forum.
I emailed to you.