Windows

Windows – Print PDF from CMD with PDFtoPrinter

In this post I will show you how to print a PDF document from the Windows command line, terminal or CMD using the executable PDFtoPrinter.exe.

As you know, printing a PDF from the Windows terminal is not possible using the print command (since it only prints text files), since a translator is required to read the content of the PDF and send it to the printer.

It is precisely what this utility called PDFtoPrinter.exe does, and in this post I’ll show you how to use it.

Downloading PDFtoPrinter

I can’t upload the executable here, but you can download it from where I downloaded it. Go to the following site: http://www.columbia.edu/~em36/pdftoprinter.html

Then click download it here.

Remember to have that executable in the same directory where you are going to invoke it from the CMD, or if you want to invoke it from anywhere, add it to the PATH.

Basic PDFtoPrinter syntax

The syntax is:

PDFtoPrinter.exe file.pdf printer

You can also indicate number of pages and other options, for this I will leave a link to the documentation.

Print PDF from Windows command line

Note: for this example I’m going to print on a thermal printer but with this utility we can print any PDF document on any printer, even one that is letter size, legal, etc. (only that right now I only have a Thermal one)

For example, I have a ticket in PDF format and the tool:

The PDF document is as follows:

ticket

Now from the CMD I navigate to that directory and run the following command:

PDFtoPrinter.exe ticket.pdf POS-58

I am invoking the utility with the name of the document and the name of the printer (my printer is POS-58):

Note: you can specify the name of the printer in quotes if you want, and also put the name of a network printer, at the end I will leave a link to some documentation.

After a few seconds it will have printed, I say it again, in my case I printed it on a thermal printer but it works for any printer.

The result after printing a PDF document from Windows CMD is as follows:

As simple as that, you can print all the documents you want and on any printer, preserving all the details.

The advantages of this

With this utility we can print from practically any language on the server side, since we only have to invoke it from the command prompt or CMD, so that we could print in the background and silently from PHP, Python, C #, Go, among others.

Note: if you want to print a ticket to a thermal printer without using PDF see this post.

References

You can find more information about this utility here. I am not related with the page or the utility in any way, I just wanter to share it and show how it is used.


I am available for hiring if you need help! I can help you with your project or homework feel free to contact me.
If you liked the post, show your appreciation by sharing it, or making a donation

parzibyte

Freelancer programmer ready to work with you. Web, mobile and desktop applications. PHP, Java, Go, Python, JavaScript, Kotlin and more :) https://parzibyte.me/

Entradas recientes

Receipt designer for thermal printers – Free and open source

In the last months I have been working on a ticket designer to print on…

11 months hace

JavaScript: store and read files with the Origin Private File System

In this post you will learn how to use the Origin Private File System with…

1 year hace

JavaScript: download file with fetch

In this post you will learn how to download a file in the background using…

1 year hace

SQLite3 with vanilla JavaScript and OPFS – Hello world

In this post I will show you how to use SQLite3 directly in the web…

1 year hace

Python Thermal Printing: A Comprehensive Guide for Printing on Thermal Printers

In this tutorial, we'll explore how to effortlessly print receipts, invoices, and tickets on a…

1 year hace

Image printing on Thermal printer

When printing receipts on thermal printers (ESC POS) sometimes it is needed to print images…

1 year hace

Esta web usa cookies.