Zebra + PHP + Linux Printer

Asked

Viewed 200 times

0

I am generating a PHP file with ZPL commands and sending it to the printer via linux command lpr -P, the problem is that in the printer is being printed the commands that are in the file and not the formatted label. Does anyone have any idea what might be going on?

Follows used code!

$lc_nome = 'rel_etiqueta.prn';
$lc_handle = fopen($_SERVER['DOCUMENT_ROOT'] . '/tmp/' . $lc_nome, 'w+');

/*
if(empty({etiquetas_por_item})||{etiquetas_por_item==0})
{
  {etiquetas_por_item} = 1;
}
*/

//var_dump([total_selecionados]);

for($x=0;$x<$tot;$x++)
{

  $linha  = explode('#', [total_selecionados][$x]);

  fputs($lc_handle,'^XA');
  fputs($lc_handle,'^MMT');
  fputs($lc_handle,'^PW831');  
  fputs($lc_handle,'^LL0240');  
  fputs($lc_handle,'^LS0 ');  
  fputs($lc_handle,'^FX  Produto Coluna 1');
   
  $nome_item    = '^FT40,60^A0N,40,30^FD'.  $linha[0] .'^FS';
  fputs($lc_handle,$nome_item);

  $codigo_item  = '^FO40,80^BC^FD'       .  $linha[1] .'^FS';
  fputs($lc_handle,$codigo_item);
  
  fputs($lc_handle,'^PQ1,0,1,Y^XZ');
  fputs($lc_handle,'^XA^ID000.GRF^FS^XZ');
  fputs($lc_handle,'^XA^ID001.GRF^FS^XZ');
  
}
        
fclose($lc_handle);

echo '</br>===== ' .  $itens . ' ===== </br>';

//$arquivo = '<a href="/tmp/rel_etiqueta.prn" target="_blank">abrir</a>';
$lc_arquivo = $_SERVER['DOCUMENT_ROOT'] . '/tmp/' . $lc_nome;
//$command = "lpr -P " . {IMPRESSORA} . " " . $lc_arquivo;
$command = "lpr -P " . 'zebra' . " " . $lc_arquivo;

//var_dump($comando);


exec($command);
  • What is the whole command called by PHP?

  • Good morning Jefferson, I edited my post with the code I’m using!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.