cocopan
cocopan

Reputation: 109

printer_open () php support, printing from web app possible solutions

Is printer_open() still supported in the latest php version? I am trying to figure out if its possible to print directly from PHP but I am not having any luck. I have found some useful questions and articles but they all use the "printer_open()" and when I try using it (even after adding the dll ext. and adding the ext to my php.ini then restarting my xampp) I get error :

Fatal error: Uncaught Error: Call to undefined function printer_open() in C:\xampp\htdocs\PHP-Printer-master\test_dll.php:6 Stack trace: #0 {main} thrown in C:\xampp\htdocs\PHP-Printer-master\test_dll.php on line 6

I also have gone into the PHP manual and can't find any refrences on this: https://www.php.net/manual-lookup.php?pattern=printer_open&scope=quickref

I get: **

"printer_open doesn't exist. Closest matches:"

**

so my best guess is that is no longer supported? but I would like to see if there is a more concrete answer/documentation proof that is been deprecated... To make sure I am not basing my decision/research on assumptions

My ultimate goal:

I have a web application form and after all the values are input I want to be able to print a receipt with no printer dialog from mobile devices, and pc . I understand there is a browser restriction so this is technically not possible. Are there any other solutions I could use? Do I have to build an app and have the users allow it in order to accomplish something like this?

I have done some research but so far the only "viable" options are: build an app, use a windows print service.

I also found this: https://github.com/mike42/escpos-php/tree/master/example and I am still unable to get this to work (printer issues) but in the mean time I wanted to get maybe some extra feedback or opinions.

I apologize I am not an expert in this subject and I am just learning about all this as I go. Any feedback will be greatly appreciated!

Thanks!

Upvotes: 0

Views: 1342

Answers (1)

Pierre
Pierre

Reputation: 649

I've encountered this use case in my own business.

You have to : - buy a Google Cloud Print enabled printer - register the printer with Google Cloud Print - create a document (receipt, invoice, etc.) in a common format, such as PDF (through some third-party PHP lib like TCPDF) - send the document to the printer through Google Cloud Print

There's no official and easy to use PHP API available for Google Cloud Print, you will have to deal with raw json POST requests or use a third-party api lib (I wrote one, available on my github).

Upvotes: 1

Related Questions