I have a website (on a remote server)and this is viewed by the user on the iPhone (Safari).
I'm trying to achieve the user being able to print a text file from that site to a POS Printer (REGO Thermal Printer, RG-MTP58B). This printer does not support AirPrint but is a wifi printer and lives on 172.20.10.2:9100
IP and port.
As far as I understand I cannot directly print from the server as the Printer is not in the server network but local network.
I'm using this package: https://github.com/mike42/escpos-php as I see is the only still maintained.
I've tried this way:
$connector = new FilePrintConnector("php://stdout");
$printer = new Printer($connector);
$printer->text("Hello World!\n");
$printer->cut();
$printer->close();
But this just gives a white page and the printer does not receive anything.
I've tried saving the file in the server, open it in Safari but Safari doesn't provide an option to print it (not even in the "Share" area).
So i found out the package Author does this:
$connector = new DummyPrintConnector();
$profile = CapabilityProfile::load("TSP600");
$printer = new Printer($connector);
$printer->text("Hello world!\n");
$printer->cut();
// Get the data out as a string
$data = $connector->getData();
// Return it, check the manual for specifics.
header('Content-type: application/octet-stream');
header('Content-Length: '.strlen($data));
echo $data;
// Close the printer when done.
$printer->close();
(original code: here)
In this case it creates a file and it shows it like this:
Again it does not provide an option to print it (not even in the "Share" area).
The file content is a binary:
<0x1b>@Hello world!
<0x1d>VA<0x03>
How do I send this data to the printer?