Some updates to PDF articles

Over the past three weeks, I've received quite a few emails asking about methods to deal with the "Can't initialize PDFCreator." error message. I've been meaning to write about it for a while, and have been responding to everyone who emailed me about it, but it took me until tonight to write up a page on it. That can be found here, and details an inelegant workaround.

I hate intentionally pausing my code, though. It feels wrong on so many levels, as we're usually trying to speed code up, not slow it down. Because of that, I've spent the last half hour looking for ways to check if the PDFCreator engine is at a point where it can be stopped, and I think I've found it. In my routines here, I ended the routines with the following code:

[vb]'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False

'Wait until the PDF file shows up then release the objects
Do Until Dir(sPDFPath & sPDFName) <> ""
DoEvents
Loop
pdfjob.cClose
Set pdfjob = Nothing[/vb]

This checks to make sure the job is printed to the printer, tells the printer that's all there is, checks to make sure the PDF file is outputted, then finally unloads the objects.

My rationale for the above was that once the file appears, PDFCreator should be finished. I'm starting to think that's not the case. If we change the Waiting portion to the code below, it seems to be reliably closing PDFCreator on my system. (PDF Creator is NOT closing with the code above)

[vb] 'Wait until the PDF file shows up then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop[/vb]

I'm curious if anyone else can reproduce this. Does the change act reliably to close PDF Creator for you as well? If it does, I see some article updates in the near future. 🙂

3 thoughts on “Some updates to PDF articles

  1. I was running into the same problem with PDFCreator.exe not shutting down. Unlike your experience, it was happening every time with my system. Adding the pdfjob.cCountOfPrintJobs=0 line fixed it.

    Very nice.

    Thanks

  2. Excellent, Phillip, thank you!

    I've been trying for a week to get to testing this at work, but alas I keep having to put out fires!

    I appreciate the feedback. 🙂

If you have a comment or question about the blog post content, please feel free to post it here. If you need help adapting this solution to your own needs, please post in our free help forum.

Your email address will not be published. Required fields are marked *