mike42 / escpos-php

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

Add a PrintConnector which uses printer_open() for raw printing #474

Open jomarlubrido opened 7 years ago

jomarlubrido commented 7 years ago

I am trying to print on shared printer, but I don't understand why I get Permission denied when using $connector = new WindowsPrintConnector("smb://Windows10-pc/".$printer_name);

but when I tried this code at the bottom it simply works, and i never added a Guest permission.

$printer = "\\".'Windows10-pc'."\".$printer_name; if($ph = printer_open($printer)){ printer_set_option($ph, PRINTER_MODE, "RAW"); printer_write($ph, $print); printer_close($ph); }

What's the explanation for this?

mike42 commented 6 years ago

Generally WindowsPrintConnector is using a net use plus a file copy to a UNC path, which doesn't require any additional dependencies.

I'll take this as a feature request to write up an alternative connector or add an option to WindowsPrintConnector to use the extension. I don't currently have a Windows install, so I'm not sure how long that will take! See also #474

If you want to use this alternative right away, then you can pull data out of the DummyPrintConnector and send it using printer_write().