You can print a PDF from the command line using one of the techniques mentioned in this article.

PDF Command Line Tool

In the program folder of the PDF printer you will find a command line tool named pdfcmd.exe. Among other things, this tool can print your PDF to a Windows printer. It can print to a physical printer or another virtual printer.

PDFCMD command="printpdf"

Additional parameters for printing PDF documents
------------------------------------------------
input                   File name of PDF document to print.
pdfprinter (optional)   Name of PDF printer used for the operation.
printer (optional)      Name of the printer that should receive the print job.
firstpage (optional)    First page to print. Default is the first page.
lastpage (optional)     Last page to print. Default is the last page.
scaletofit (optional)   Scale output to fit (yes|no). Default is yes.
bpp (optional)          Bits per pixel. Valid values are 1, 4, 8, 24 (default).
docname (optional)      Document name in printer queue.
maxdpi (optional)       Maximum DPI resolution to print.
timeout (optional)      Maximum timeout in seconds for the merge
                        to finish. The default is 60 seconds.

Example:
PDFCMD command=printpdf input="C:\Temp\A.pdf"

One of the benefits of this tool is that it does not depend on a PDF Viewer being installed on the machine that prints the PDF.

It is most suited for sending the PDF to a physical printer because it sends the PDF to the printer as a bitmap. This means that the vector information stored in a normal PDF is not preserved. In case you want to create a new PDF from the print job, then you will find that it looks pixelated if you zoom the PDF view.

Using this option to print the PDF from a command line is good if you find the output quality acceptable.

SumatraPDF Reader

In this approach, you can use the free SumatraPDF Reader to print the PDF. The SumatraPDF Reader can print a PDF from a command line.

The benefit from using this method over the pdfcmd mentioned above is that the vector information is preserved and if you print the PDF to another PDF or XPS then you may find that the quality is better.

1) Printer API: PrintFile method

The PrintFile method of the API will ask the operating system to print the file to a specific printer. It uses a feature of the operating system called the printto verb.

Verbs are actions that Windows can do on a file. Different programs register themselves with different verbs on file types they support. As an example the printto verb of .doc and .docx files is usually handled by Microsoft Word.

If no printto verb is registered for PDF files then this method will not be able to print PDF files. We recommend using the SumatraPDF Reader (Installer Version) will register itself for the printto verb of PDF files.

The following VB script show how the COM edition of API can be used with this method.

    Rem -- Create the COM helper object.
    set util = CreateObject("pdf7.PdfUtil")
    
    Rem -- Print the file to a specific printer
    util.PrintFile "C:\Test Page.pdf", "7-PDF Printer"
    

2) Printer API: PrintPdf method

You can also use the PrintPdf method to print PDF files. This is the API equivalent of the command line tool pdfcmd mentioned above.

The following VB script show how the COM edition of API can be used with this method.

    Rem -- Create the COM helper object.
    set util = CreateObject("pdf7.PdfUtil")
    
    Rem -- Print the file to a specific printer
    util.PrintPdf "C:\Test Page.pdf", "specific", "7-PDF Printer", "7-PDF Printer", False, 24, "Print PDF Example", 300, True, 1, 0, 10000
    
    

Top