escpos-php icon indicating copy to clipboard operation
escpos-php copied to clipboard

How to print from my server to the client web browser?

Open lebroncho opened this issue 4 years ago • 9 comments

Hello. I was trying to print my receipt in my browser coming from the server. I am using windows server and I able to access it using a virtual box. I had a question earlier which lead that I try this code $connector = new WindowsPrintConnector("smb://mycomputername/posprinter"); . It would produce an error since the server is restricted hence it would not see my computer in server's networks. Is there another way to be able to print the receipt from my web browser which my web is deployed in the windows server. In my windows server, I am using XAMPP

Code in my Laravel Controller

$connector = new WindowsPrintConnector("smb://mycomputername/posprinter"); 
$printer = new Printer($connector);
$printer->text("Hello World\n");
$printer->cut();
$printer->close();

lebroncho avatar Feb 20 '20 03:02 lebroncho

Did you solve that problem? I've same issue.

kdrmlhcn avatar Apr 17 '20 19:04 kdrmlhcn

I solved that, if you want i can help you. [email protected]

kdrmlhcn avatar May 07 '20 18:05 kdrmlhcn

Yes sure can you share it here your solution sir?

lebroncho avatar May 10 '20 05:05 lebroncho

Hi @kdrmlhcn how do you solve it?

agustinbus avatar Nov 19 '20 20:11 agustinbus

I developed an electron app with npm-escpos package 👍🏻 @agustinbus @jecfarolan360

kdrmlhcn avatar Nov 19 '20 21:11 kdrmlhcn

Hi sir iam trouble with the same issue can you help me to find this please. @kdrmlhcn

muhammadmarwan avatar Jun 06 '21 11:06 muhammadmarwan

Hello, you can develop an electron desktop application using with node.js backend and node-escpos library. Your website should has API that will list new orders. Then you'll check the API each 5 seconds on electron app. If there is an order will print the bill with node-escpos. @muhammadmarwan

kdrmlhcn avatar Jun 06 '21 16:06 kdrmlhcn

@kdrmlhcn mind sharing a link to a sample repo of the above?

mutiemule avatar Apr 10 '22 19:04 mutiemule

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. 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.

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.

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

mutiemule avatar Apr 30 '22 09:04 mutiemule