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.
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.
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.
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:
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.
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.
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.
In the last months I have been working on a ticket designer to print on…
In this post you will learn how to use the Origin Private File System with…
In this post you will learn how to download a file in the background using…
In this post I will show you how to use SQLite3 directly in the web…
In this tutorial, we'll explore how to effortlessly print receipts, invoices, and tickets on a…
When printing receipts on thermal printers (ESC POS) sometimes it is needed to print images…
Esta web usa cookies.