biopdf logo
Shortcuts

Customers

Download PDF Writer

Other Tools
Command line printing with Acrobat Wrapper

Awards & Press
PC Magazine

CHIP.de Online

CNet

ZD Net

XKnowledge

SnapFiles


Print PDF From Command Line

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 the Adobe Reader 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.

Acrobat Wrapper

In this approach, you can use the Acrobat Reader to print the PDF. The Adobe Reader can print a PDF from a command line but it has some drawbacks. The most important drawback is that the reader does not close itself after printing the PDF. You can overcome this problem by using the Acrobat Wrapper.

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.

Printer API

PrintFile

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. The Adobe Reader will register itself for the printto verb of PDF files. Consider installing the Acrobat Wrapper to take over this verb if you want to be able to close the Adobe Reader after printing.

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("biopdf.PdfUtil")

Rem -- Print the file to a specific printer
util.PrintFile "C:\Test Page.pdf", "PDF Writer - bioPDF"

PrintPdf

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("biopdf.PdfUtil")

Rem -- Print the file to a specific printer
util.PrintPdf "C:\Test Page.pdf", "specific", "PDF Writer - bioPDF", "PDF Writer - bioPDF", False, 24, "Print PDF Example", 300, True, 1, 0, 10000
 
McAfee SiteAdvisor Norton Safe Web