Skip to content

Instantly share code, notes, and snippets.

@ihussain1024
Last active May 26, 2018 09:49
Show Gist options
  • Save ihussain1024/4772071cf1ff2068cf19cc6146d08142 to your computer and use it in GitHub Desktop.
Save ihussain1024/4772071cf1ff2068cf19cc6146d08142 to your computer and use it in GitHub Desktop.
Zpl Barcode printing using PHP
// First create a file called 'text.zpl' in root folder like 'barcodeprinter', and then paste the codes in index.php page
$str_header="Code 128";
$str_footer="Footer Text";
$barcode_data="1234567890";
$content = "^XA^FO230,20^AD^FD".$str_header."^FS^FO230,135^AD^FD".$str_footer."^FS^FO230,40^BY2^BCN,70,Y,N,N^FD".$barcode_data."^XZ";
$fp = fopen($_SERVER['DOCUMENT_ROOT']."/barcodeprinter" . "/text.zpl","wb");
fwrite($fp,$content);
fclose($fp);
exec('lpr -P ZebraPenguin text.zpl');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment