mike42 / escpos-php

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

EPSON LX 310 Cannot print using WindowsPrintConnector on live server #687

Closed jeimaisio closed 5 years ago

mike42 commented 5 years ago

The LX310 is an ESC/P printer, and this is an ESC/POS library. They sound similar, but the protocols are quite different.

This means that anything more complex than "Hello world" will most likely print gibberish on that printer. See also "I have a printer that does not understand ESC/POS. Can I use this driver?" in the FAQ.

jeimaisio commented 5 years ago

This code works well on my local but when uploaded to server, to AWS it returns an error that smbclient command not found. $connector = new WindowsPrintConnector("EPSON LX-310"); //Printer Share name $printer = new Printer($connector);

Then I installed samba client on aws. Now it return error "Failed to print. Command "smbclient '//ip-123-456-789/EPSON LX-310' -c 'print -' -N -m SMB2" failed with exit code 1: Connection to ip-123-456-789 failed (Error NT_STATUS_UNSUCCESSFUL)"

Hope you can help me to solve this.

mike42 commented 5 years ago

Well, I'll set aside the compatibility problem for a moment.

This is a server-side library, and your AWS box cannot see your printer. Please check out "Can I print from my server on the Internet?" in the FAQ.

jeimaisio commented 5 years ago

Already trying to apply the suggestions on the link you gave. I'll give you an update on what happen. Hope you can help me to solve this.

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.