Ghulam.M
Ghulam.M

Reputation: 113

Check Printer Status in PHP7

I'm testing below code to print labels with custom text

    $outputString='^XA
^FO100, 200
^AD,50,25
^FH_^FD Hello world _7E ^FS
^XZ';
     $Ip='xxx.xxx.x.xx';
     $port='xxxx'
        $fp = fsockopen($Ip, $port, $errno, $errstr);
    if (!$fp) {
        echo "$errstr ($errno)<br />\n";
    } else {
        try {
            $kk=fwrite($fp, $outputString, strlen($outputString));
            fclose($fp);
            echo 'Successfully Printed';
        } catch (Exception $e) {
            echo 'Caught exception: ', $e->getMessage(), "\n";
        }
    }

It is working fine but I am looking for way to find out any method or way to find out if the printer has printed the data successfully i.e if there is no paper it still prints Successfully Printed

Upvotes: 0

Views: 998

Answers (1)

Mark Warren
Mark Warren

Reputation: 1491

What you want is the ZPL command ~HS (Host Status). It returns a three line response with lots of useful information about the current state of the printer. The first two lines provide flags for label present, paper out, head up, over/under temperature, etc.

See https://www.zebra.com/content/dam/zebra/manuals/printers/common/programming/zpl-zbi2-pm-en.pdf for more details

Upvotes: 2

Related Questions