3

I own Sewoo Thermal Printer that is connected to a local PHP point of sale. Now as a simple print test using php, I wrote the following code :

<?php
$handle = printer_open("THERMAL LK-TXXX");
$handle = printer_open();
?>

And I got this Error :

Fatal error: Call to undefined function printer_open() in C:\wamp\www\frame\reciept.php on line 2

I'm using Wampp as my web server, Windows 7 and I've installed the correct drivers for my printer. How can i fix this problem, Or is there an alternative "Print" methode using PHP to automatically print without showing Print preview?

Thank You

René Höhle
  • 26,716
  • 22
  • 73
  • 82
Alihamra
  • 454
  • 2
  • 10
  • 28
  • 2
    The printer functions are not included in the default PHP distribution. You need to [install them](http://php.net/manual/en/printer.setup.php). – zneak Dec 31 '12 at 15:51
  • Are you sure that the printer extension is installed? – bear Dec 31 '12 at 15:52
  • I assume you are using a 3rd party library, and in that case you need to include the library: `require_once "printer_library.php";` before you run your functions – Get Off My Lawn Dec 31 '12 at 15:52
  • In fact, the PHP printer extension hasn't been modified since PHP 4.0.4. You will probably need another solution. – zneak Dec 31 '12 at 15:53
  • I don't have printer extension, Where do i find them? – Alihamra Dec 31 '12 at 15:54
  • Ok What if I used Javascript print instead, It works perfectly but I don't want to see the Print screen. Is there a way to disable it ? – Alihamra Dec 31 '12 at 15:55
  • @Alihamra are you find the solution,if then please guide me.Thank You. – Raham Nov 30 '15 at 07:38

2 Answers2

5

A POS printer is (mostly) not a printer in the sense of using the Windows printing functions to create output, that is quite independent of the device, but simply a sink for serial data in the printer's control language (we built a ticketing system driving very similar printers).

One approach is to user the Win32API extension for PHP and the OpenDriver API, but this turns out to be quite a mess. Best way is to simply fopen() the printer port and write your PCL data via fwrite()

Eugen Rieck
  • 64,175
  • 10
  • 70
  • 92
  • How would you `fopen` the printer port? Do they have a "path"? – zneak Dec 31 '12 at 15:54
  • How can I find the Printer Port? Please Help ! – Alihamra Dec 31 '12 at 15:56
  • Depending on how the printer is attached, there are lots of possibilities. If it is serial or parallell (or USB to serial inside the printer), which is quite common with these beasts, just use `COMn:`. If it is USB-connected (logically, not only physically) use something like http://www.andtechnologies.com/index.php?q=free-software/dosprint – Eugen Rieck Dec 31 '12 at 15:58
0

You are probably getting this error because the printer extension is not installed. From the PHP manual:

Installation

This » PECL extension is not bundled with PHP.

Windows users must enable php_printer.dll inside of php.ini in order to use these functions. A DLL for this PECL extension is currently unavailable. See also the building on Windows section.

Installation instructions can be found here: http://php.net/manual/en/install.windows.building.php

Andreas Hagen
  • 2,335
  • 2
  • 19
  • 34