Scripting PDF Creation

孤街浪徒 提交于 2020-01-04 06:37:30

问题


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:


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.




回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/1627497/scripting-pdf-creation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!