0

I want to print .pdf files on a Zebra ZT411 via PHP or Cups.

I am currently using a PHP script which extracts labels from my database and sends them to the printer. Currently they are all formatted in ZPL. This works perfectly. Now I want to send PDF files to the Zebra printer. Unfortunately, this does not work like ZPL by simply sending it to the printer via port 9100. I have already tried to solve this via a CUPS but unfortunately this did not work.

Code for ZPL print:

$fp = @pfsockopen($printer_out, 9100, $errno, $errstr);
fputs($fp, $zpl_string);
fclose($fp);

2
  • Does this answer your question? Print to Zebra printer in php Commented Mar 12, 2024 at 15:10
  • The most universal method is to convert the PDF to a monochrome PNG image. The conversion will need to match the dpi of the printer, typically 203dpi. Once you have the PNG, it is straightforward to send directly to the printer with a bit of ZPL. Commented Mar 12, 2024 at 15:50

1 Answer 1

1

The easiest way is to enable PDF direct on the printer, which is a emulator for PDF that allows the printer to process PDF files without any conversion. This emulator is embedded in the latest firmware, so most likely you'll just have to activate it. Search for PDF direct on the Zebra support community and you'll find how to activate it.

Sign up to request clarification or add additional context in comments.

2 Comments

do you have an example how to post a PDF to Zebra printer? I have currently this which does not work: $connection = fsockopen($ip, $port, $errno, $errstr); $fileContent = file_get_contents($pdfPath); $fputs = fputs($connection, $fileContent, strlen($fileContent)); fclose($connection);
sorry for the late response, try the following $port = 9100; $sec = 8; $usec = 0; $socket = @socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec'=>$sec, 'usec'=>$usec)); socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, array('sec'=>$sec, 'usec'=>$usec)); socket_connect($socket, $printer_ip, $port); $file = file_get_contents($_FILES["filename"]); socket_write($socket, $file, filesize($_FILES["filename"])) or die ("Host unreachable");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.