Print to external receipt printer using PHP

12k views Asked by At

I'm trying to find a solution for sending live orders to a receipt printer.

Basically in pseudo-code:

if ($order == 'success')
{
    $printer = ip.to.remove.printer;

    $receipt_text = 'You just received an order!';

    $ch = curl_init('http://addresstosomekindofapi.com/print_receipt/');
    curl_setopt($ch, SOME_OPTION, 0).............;

    curl_exec($ch);
    curl_close($ch);
}

I'm just exploring options in getting this done. It would be awesome to be able to do this rather than send faxes which often have tied up lines, etc, etc.

How could one achieve this?

3

There are 3 answers

1
Saad On BEST ANSWER

To me, a solid solution is to build a desktop application that is connected to your web application and has the ability to send jobs to the printer. I don't think a web application can have much of control as to handle user's print jobs.

0
Nanne On

There are printers (like your basic office hp laserjets I guess) that can

  • Be reached trough ftp
  • Have 'virtual printer' modes for paper selection.

I'd look into that if I were you.

(this was assuming there is some sort of network separation between the printer and the php file.)

0
Ezekiel On

I think that the best solution to your problem is printing the document to pdf using a php class for printing to pdf. There are quite a few of such classes. A good one is ezpdf class which can be downloaded from http://www.ros.co.nz/pdf or http://www.sourceforge.net/projects/pdf-php