开发者

Scripting PDF Creation

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 PD开发者_JAVA技巧FCreator 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.


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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜