How do I print a file from the command line?

Is there a way to run the file through the printer driver without opening the application?

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

+6
source share
4 answers

Since this is a .docx file, Microsoft Word is probably the best program to complete the task.

I would look at the command line arguments in Word:

http://winhlp.com/WordCommandLineSwitches.htm

Look at the following switches:

/q , /n , /mFilePrintDefault and /mFileExit

( /q and /n described on the page above and /mXxxx refer to macros. Take a look at google.)

Example:

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

The next page seems to explain how to convert it to PDF

http://www.suodenjoki.dk/us/productions/articles/word2pdf.htm

+8
source

What you are looking for is called the "headless start" of the program you want to print. I know for sure that OpenOffice can do this. Basically, you need to run it and invoke a macro that will print. Moreover, you can print in PDF, HTML or something else that supports Oo.

This negates the need to install Microsoft Word and the cost of the license, since OpenOffice is free.

0
source

If you are looking only for automatic .docx printing then [aioobe] answer is the best. If you want to use a more general, non-print printing 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 :)

0
source

You might be interested in DocTo , which converts a Word document to a different file format, including pdf and XPS, but requires Word on your computer.

For instance,

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

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

0
source

Source: https://habr.com/ru/post/1308522/


All Articles