-
-
Save Pax125/8ff4b1d51b16e5b2abbe55028d1296b7 to your computer and use it in GitHub Desktop.
PHP script that executes lpr program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function print_labels($files) | |
{ | |
$cmd = '/usr/bin/lpr -PDYMO_LabelWriter_450_Turbo -o PageSize=w102h252.1 -o PageRegion=w102h252.1 -o landscape -o page-left=10 -o page-top=10 -o page-right=0 -o page-bottom=0 -o Resolution=300dpi -o cupsDarkness=Normal -o scaling=100 '.$files; | |
$output = system($cmd, $ret); | |
if($ret!=0 || $output!='') | |
{ | |
return 'ERR ['.$ret.']: '.$output; | |
} | |
$cmd = '/usr/bin/lpq -PDYMO_LabelWriter_450_Turbo | head -n1 | grep -q "is ready$"'; | |
$idx=0; | |
while(TRUE) | |
{ | |
$output = system($cmd, $ret); | |
if($idx > 120 && $ret!=0) | |
return $output; | |
if($ret==0) | |
return TRUE; | |
sleep(1); | |
$idx++; | |
} | |
return TRUE; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment