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 print from my server to the client web browser? #882

Open lebroncho opened 4 years ago

lebroncho commented 4 years ago

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();
kdrmlhcn commented 4 years ago

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

kdrmlhcn commented 4 years ago

I solved that, if you want i can help you. kadirmelihcan@gmail.com

lebroncho commented 4 years ago

Yes sure can you share it here your solution sir?

agustinbus commented 3 years ago

Hi @kdrmlhcn how do you solve it?

kdrmlhcn commented 3 years ago

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

muhammadmarwan commented 3 years ago

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

kdrmlhcn commented 3 years ago

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

mutiemule commented 2 years ago

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

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