views:

106

answers:

3

I've been tasked with automating the collection of some reports from our remote locations. The machines are sometimes used locally by the staff at the location, and their usage is random. The software that generates the reports is somewhat limited and just allows us to print to the default printer. The department that's taking these reports doesn't want anything to change, and they enjoy getting their PDFs.

I can programmatically change the default printer to use the PDFCreator printer (and switch it back so the staff at the location won't notice), and I can programmatically generate the report and send it to printer.

My problem is that doing so pops up a window from PDFCreator wanting a file name and some meta-data for the PDF.

I'd like to minimize the windows popping up, and hopefully make my gathering of the reports as unobtrusive to the local users as possible.

Is there a simple way to automate the PDFCreator interaction, or am I left with using SendMessage (or similar) and simulating user interaction?

PDFCreator isn't required, I'd also take suggestions for other PDF-print-type pieces of software that solves this problem, too.

+1  A: 

AFAIK, you're left with playing with SendMessage games. It's not that bad, grab a copy of Spy++ and have fun!

omghai2u
+1  A: 

PDFCreator is a VB wrapper round ghostscript so you should be able to modify PDFCreator to not pop the dialog up and give it the filename in some other way.

Alternatively you could use a postscript printer driver with output directed to FILE: and then you can programmatically call ghostscript to convert the PS to PDF yourself. I can't see a way to stop the windows built-in postscript drivers from creating a dialog when port is set to FILE: and when port is set to PSFile I can't figure out where the file goes. However GSPSprinter.html has instructions for how to set up a Ghostscript postscript printer to a fixed file location so you should get no dialogs.

danio
I like the idea of just calling Ghostscript directly. Assuming I can take care of converting the PS to PDF (using the Ghostscript DLL, I guess?), how do I get the software to spit out the PS file to begin with?
mrduclaw
@mrduclaw I've modified my answer to address this, but basically you use a postscript printer driver (e.g. apple laserwriter is built into windows) and redirect output to file.
danio
@danio Thanks so much for your help!
mrduclaw
A: 

The PDFCreator command line help says that you can pass /NoStart to close the print window you can provide an .INI file this way :

"C:\Program Files\PDFCreator\PDFCreator.exe" /NoStart /OptionsFile"C:\dev\convert\convert.ini" /PF"DOC_TO_CONVERT.doc"

that contains "auto" options :

[Options] UseAutosave=1 UseAutosaveDirectory=1 AutosaveFormat=pdf AutosaveDirectory= NoConfirmMessageSwitchingDefaultprinter=1

CC