Direct print to a COM Port 3 Printer

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
DaveyCrocket
Forum Newbie
Posts: 1
Joined: Wed Oct 21, 2009 5:39 am

Direct print to a COM Port 3 Printer

Post by DaveyCrocket »

Hi,

I am building a site and at certain points in the site, I need to fire off some code that tells a receipt printer to print off what I tell it to.

I found some code that works if the printer is plugged into a parallel port (see below)

Code: Select all

$handle = fopen('PRN', "w"); // note 1
    fwrite($handle, 'text to printer'); // note 2
    fclose($handle); // note 3
However, my client has been fairly specific in telling me that the printer MUST be plugged into Comm Port 3.

I tried altering the code above to use 'COM3' instead of 'PRN' but no result.

Basically, is there anyway to get PHP to automatically print without having to use a print prompt window (for example by using the js window.print() function). I know my client will not like the idea of users having to click another button.

Is there anyway to do this? Or is it possible that I can auto print a pdf file. I just want to exhaust all options before telling my client he is going to have to use a print window.

Thanks for any help and if you need more info, let me know.

P.S. If it makes any difference to how it would work, the printer I am using is an Epson Thermal line Printer TM-T88III
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Direct print to a COM Port 3 Printer

Post by VladSun »

I suppose it's Windows OS ...
http://php.net/manual/en/book.printer.php
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply