mike42 / escpos-php

PHP library for printing to ESC/POS-compatible thermal and impact printers
Other
2.54k stars 862 forks source link

How to printer directly from web browser to printer? #818

Closed pandasolutionkh closed 4 years ago

pandasolutionkh commented 4 years ago

Hello Everyone,

Currently, i have problem with printer of POS Cloud because i cannot print directly to printer from web browser. we still wait for Print Preview?

Do you have any idea how to print directly from client side?

Best Regards,

PandaSolution.

ththo59 commented 4 years ago

you can use library: https://github.com/mike42/escpos-php. I hope can help you.

Muraveiko commented 4 years ago

For android https://play.google.com/store/apps/details?id=com.fidelier.posprinterdriver https://play.google.com/store/apps/details?id=pe.diegoveloper.printerserverapp https://play.google.com/store/apps/details?id=ru.a402d.rawbtprinter for last see example https://github.com/mike42/escpos-php/blob/development/example/rawbt-receipt.html

For windows https://qz.io/

other solutions based on local machine listen tcp port server

mike42 commented 4 years ago

Closing this off as it's not clear how escpos-php is being used, if at all.

If you are using this library, please include a minimal PHP snippet which shows the problem. We do raw printing directly from PHP to the printer, so the browser's print function would not be used.

mutiemule commented 2 years ago

Printing on local will work well with this package.

However, to print online, you will need to develop a desktop service which has to be installed on the local computer where you need printing to be done. This is because PHP is a server-side scripting language, so once you put this online, it won't be able to communicate to the local printer. Thus, you need a client service running on the local machine and this is where electron js and node js come into play.

I resolved this by developing an electron js service based on node-escpos package which can receive commands from the online print command and then communicate those commands to the printer through USB.

Operating System does not matter in this case, you can be hosting on Linux based server and printing on a windows server. This desktop service interfaces between the online service and the local service.

You can check out the node-escpos printer driver package for some inspiration on how to go about this.

Check the FAQs on how to print online to have some pointers too.