I have a Canon iSensys MF217w that is connected to a public IP address. I need to be able to print to this printer directly from our website from which we print orders.
This is the code that I use:
$outputString = "Hello World!";
$Ip = "xxx.xxx.xxx.xxx";
$port = "9100";
$fp = fsockopen($Ip, $port, $errno, $errstr, 15);
if (!$fp) {
echo json_encode("$errstr ($errno)<br />\n");
} else {
try {
$kk=fwrite($fp, $outputString, strlen($outputString));
fclose($fp);
} catch (Exception $e) {
echo json_encode('Caught exception: ', $e->getMessage(), "\n");
}
}
This code works perfectly fine to any other printer except the Canon printer.
fsockopen() is successfull as I don't receive any errors but the printer does not print the print job.