如何从命令行打印文件?
有没有办法通过打印驱动程序运行文件而不打开应用程序?
例如:运行 .docx 文件,而不打开 Word,并将其保存到文件?
Is there a way to run a file through a print driver without opening the application?
Ex: run a .docx file, without opening word, and save it to file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
由于它是
.docx
文件,因此 Microsoft Word 可能是执行此任务的最佳程序。我想看看 Word 的[命令行参数]:
看看以下开关:
/q
、/n
、/mFilePrintDefault 和
/mFileExit
(
/q
和/n
已在上页中解释,/mXxxx
指的是看看谷歌。)示例:
以下页面似乎解释了如何将其转换为PDF。
Since it is a
.docx
-file Microsoft Word is probably the best program to do the task.I would have a look at the [command line arguments] to Word:
Have a look at the following switches:
/q
,/n
,/mFilePrintDefault
and/mFileExit
(
/q
and/n
explained in the page above, and/mXxxx
refers to macros. Have a look att google.)Example:
The following page seems to explain how to convert it to PDF.
您正在寻找的是需要打印的程序的“无头启动”。
我确信 OpenOffice 可以做到这一点。
基本上,您需要启动它并调用一个宏来执行打印。更重要的是,您可以打印为 PDF、HTML 或 Oo 支持的任何其他格式。
这样就无需安装 Microsoft Word 和许可证费用,因为 OpenOffice 是免费的。
What you are looking for is called "headless start" of the program which needs to print.
I know for sure that OpenOffice can do this.
Basically, you need to start it and invoke a macro which will do the printing. Even more, you can print to a PDF, HTML, or anything else that Oo supports.
This negates the need for install of Microsoft Word and the cost of license, because OpenOffice is free.
如果
将这样的内容添加到normal.dotm:
然后按照上面的详细说明从命令行调用,例如:
If
Add something like this to normal.dotm:
Then call from the command line as detailed above, such as:
如果您只寻找 .docx 无声打印,那么 [aioobe] 答案是最好的。如果您想要在 Windows 上运行的更通用的静默打印程序,请使用 powershell 或 .NET 并使用 print 动词。 http://www .eggheadcafe.com/software/aspnet/30441939/how-to-suppress-printdialog-when-using-print-verb.aspx 提供了一个示例。
希望这有帮助,如果有的话请+1:)
If you are looking only for .docx silent printing then [aioobe] answer is the best. If you want a more generic silent print program that runs on Windows, use powershell or .NET and use the print verb. http://www.eggheadcafe.com/software/aspnet/30441939/how-to-suppress-printdialog-when-using-print-verb.aspx provides an example.
Hope this helps, if so +1 please :)
您可能对 DocTo 感兴趣,它将 Word 文档转换为其他文件格式,包括 pdf 和 XPS,但是确实需要机器上有Word。
例如
将 mydocument.docx 作为 pdf 文件输出到 c:\output\mydocument.pdf。
You might be interested in DocTo which will convert a word document to another file format, including pdf and XPS but does require Word on the machine.
For example
Will output mydocument.docx to c:\output\mydocument.pdf as a pdf file.