PDFtoPrinter: Command-line PDF printing


A utility that prints PDF files from the Windows command line

PDFtoPrinter is a program for printing PDF files from the Windows command line. You may download it here.  The program is designed generally for the Windows command line and also for use with the vDos DOS emulator (see below). (December 2017: revised version with customization option described below.)

The program is a compiled AutoIt script that effectively serves as a "wrapper" around the free PDF-Xchange Viewer, which is included in the PDFtoPrinter program itself. PDF-Xchange Viewer is the only no-cost PDF software that I know of that does all of the following:

You can use PDF-Xchange Viewer to do everything that the PDFtoPrinter program can do, but PDFtoPrinter is easier to use for its single purpose of printing from the command line. Also, PDFtoPrinter requires no setup and always maintains the correct settings for its single purpose. PDF-Xchange Viewer, when used as a standalone program, is infinitely more flexible, but at the cost of easily losing the settings required for "Select paper source from page size."

Note: If your antivirus software mistakenly tells you that the PDFtoPrinter program is dangerous (because your antivirus software ignorantly warns about any program created with AutoIt), it is up to you to decide whether or not to believe your antivirus software. If you don't trust this software, don't use this software! Don't waste your valuable time sending me an e-mail asking whether the program is safe!

To print a PDF file to the default Windows printer, use this command:

PDFtoPrinter filename.pdf

You can use a full path for the filename, but if the path or filename contains spaces, use quotation marks around the path and filename.

Alternatively, you can simply drop a PDF file on to the application (or on a shortcut to it).

To print to a specific printer, add the name of the printer in quotation marks:

PDFtoPrinter filename.pdf "Name of Printer"

If you want to print to a network printer, use the name that appears in Windows print dialogs, like this (and be careful to note the two backslashes at the start of the name and the single backslash after the servername):

PDFtoPrinter filename.pdf "\\SERVER\PrinterName"

If you mistype the printer name or specify a printer that does not exist, nothing will print, but no error message will be displayed.

If you want to select from a list of installed printers, change the name of the program to PDFtoPrinterSelect.exe. When launched, it will pop up a list of installed printers, unless you specify a printer name on the command-line, in which case it will print to the specified printer, without displaying a menu.

Customization: By default, this system uses these printing options as set in PDF-XChange Viewer: Scaling is set to None; Auto-rotate Sheets; Auto-centre pages in sheets; and Choose paper source by PDF-page size. If you want to change any of these, or choose any other options, download and install PDF-XChange Viewer; open a PDF file, go to the Print menu, set your desired options (and, just to be certain, print the file). Then go to the Edit menu and choose Export All Settings to Data File... Accept the suggested filename, "PDF-XChange Viewer Settings.dat", and save the file to a convenient location. Move or copy the file to the same folder with PDFtoPrinter.exe. When you next run PDFtoPrinter.exe it will use the settings saved in that file.

Duplex printing: PDF-XChange Viewer cannot save a duplex-printing option as the default. To print in duplex mode, modify the settings of your Windows printer (in the Windows Control Panel or Settings app) to enable duplex printing, or create a duplicate copy of your Windows printer, set it to print in duplex by default, and specify that printer when running PDFtoPrinter.exe. Search the web if you don't know how to create a duplicate copy of your Windows printer or if you don't know how to specify duplex printing in your Windows printer properties.


Printing from vDos (and vDosPlus)

You may use this program with vDos to print PCL or PostScript output to any Windows printer (applies to vDos 2016.10.01 and later versions only). Place PDFtoPrinter.exe in the folder with the vDos.exe program. If you want to print PCL output, you must add pcl6.exe to the same folder; if you want to print PostScript output, you must add gswin32c.exe to the same folder.  If you do not have these files, you may download them here (from the vDosPCLPS.zip archive linked near the top of the page). Then use this syntax in config.txt (replacing LPT1 and #LPT1.PDF with LPT2 and #LPT2.PDF, etc., if needed):

LPT1 = "PDFtoPrinter.exe" #LPT1.PDF

You can specify a printer by adding the printer name in quotation marks, like this:

LPT1 = "PDFtoPrinter.exe" #LPT1.PDF "Microsoft XPS Document Writer"

If you want to print to a network printer, use the name that appears in Windows print dialogs, like this (and be careful to note the two backslashes at the start of the name and the single backslash after the servername):

LPT1 = "PDFtoPrinter.exe" #LPT1.PDF "\\SERVER\PrinterName"

If you want to select from a list of installed printers, change the name of the program to PDFtoPrinterSelect.exe (and, of course, change the line in config.txt to refer to "PDFtoPrinterSelect.exe"). The program will pop up a list of installed printers, unless you specify a printer name in the command string, in which case it will print to the specified printer, without displaying a menu.

Use the same procedure with vDosPlus (2016.10.01 and later versions only), placing the additional files in the same folder with vDosPlus.exe


Licensing

This system uses the free PDF-Xchange Viewer. You should consult the linked page to determine whether or not you may use that program for your own purposes. The compiled AutoIt script that wraps the PDF software is free for use by anyone, anywhere, for any purposes whatever.


Edward Mendelson (em thirty-six [at] columbia [dot] edu, but with two initials and two numerals before the [at] sign, not spelled out as shown here).