I have a webshop (on a webserver) where customers can order things, somewhere else (at the customers company) I have a printer which needs to instantly print an packing slip whenever the website receives an order.
I’m totally free in what to use and how to connect the printer (preferably directly on router or on Windows PC).
Numerous of options but I’m not sure which one is most reliable (given the fact that the order needs to be printed instantly)… Also, the printer / API / software needs to be able to give alert feedback when the printer is offline so a SMS or something can be sent.
I know all about PHP, so using any form of API isn't a problem.
$content = "Firts Line
";
$content .= "Second Line";
$content .= char(27).char(ord("E")); // ESC E (command ESC for thermal printers)
$content .= "Line with effect ESC";
$f = @fsockopen($print_ip,$print_port,$errno,$errstr);
if (!$f) {
echo "Erro: $errstr<br/>";
if ($errstr=='No route to host') { die("Verify conncetion."); }
}
else {
if(fwrite($f, $content)) { echo 'success.'; }
@fclose($f);
}