开发者

How can I print a file from the command line?

开发者 https://www.devze.com 2022-12-29 00:19 出处:网络
Is there a way to run a f开发者_StackOverflowile through a print driver without opening the application?

Is there a way to run a f开发者_StackOverflowile through a print driver without opening the application?

Ex: run a .docx file, without opening word, and save it to file?


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:

WINWORD.EXE your_document.docx /mFilePrintDefault /mFileExit /q /n

The following page seems to explain how to convert it to PDF.


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.


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 :)


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

Docto -f "c:\docs\mydocument.docx" -o "c:\output" -t wdFormatPDF 

Will output mydocument.docx to c:\output\mydocument.pdf as a pdf file.

0

精彩评论

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

关注公众号