Lançado Adianti Framework 7.6!
Clique aqui para saber mais
Relatório FPDF mandar direto para impressora Bom dia, não sei se tem como, fiz um relatório FPDF e gostaria de imprimir o pdf gerado direto para impressora. ou outra solução ...
RS
Relatório FPDF mandar direto para impressora  
Bom dia, não sei se tem como, fiz um relatório FPDF e gostaria de imprimir o pdf gerado direto para impressora.
ou outra solução

Curso completo Meu Negócio Pronto
Use para si, ou transforme em um negócio: Inclui aulas e códigos-fontes
Gestor de conteúdo (SITE) + Loja Virtual (E-Commerce) + Emissor de Notas para infoprodutos


Meu negócio pronto Quero me inscrever agora!

Comentários (4)


NR

Se a impressora estiver em rede, pode usar um servidor de impressões(cups, por exemplo), e imprimir por linha de comando. Se estiver local, aí desconheço uma solução única. Sei que o chrome tem uma opção "kiosk mode" que possibilita, entre outras coisas, a impressão direta(faz tempo que usei, precisa ver se ainda funciona). Provavelmente existam outras extensões para o chrome e demais navegadores.
RS

Achei a solução, estou usando, bem bacana e fácil


https://github.com/mike42/escpos-php
PG

Boa Tarde, como vc implementou isso no adinati,
tem com dar umas dicas, estou precisando imprimir,
pedido de venda em impressora termica.
Obrigado.
RS

boa tarde, baixar e coloquei a pasta Mike42 no meu projeto, fora do app depois so usei ela no começo da minha classe.

?php
use Mike42EscposPrinter;
use Mike42EscposEscposImage;
use Mike42EscposImagickEscposImage;
use Mike42EscposPrintConnectorsFilePrintConnector;
use Mike42EscposPrintConnectorsWindowsPrintConnector;

class DeliveryList extends TPage
{
protected $form; // registration form
protected $datagrid; // listing
.........
?>


aqui para imprimir, metodo onImprimir


  1. <?php 
  2.  public function onImprimir($param)
  3.     {
  4.     
  5.         try    
  6.         { 
  7.         
  8.           if(empty($param['key'])){
  9.           
  10.          
  11.           $key $param['key']; // get the parameter $key
  12.           
  13.           TTransaction::open('sgbr'); // open a transaction with database
  14.             
  15.           $object = new Vendas($keyFALSE); // instantiates the Active Record
  16.           
  17.           $atendente  SystemUser::findInTransaction('permission'$object->usuario)->login;
  18.           
  19.           $config     Config::find('1');
  20.           $cobrartaxa $config->taxa_servico;
  21.           $p_taxa     $config->p_taxa;
  22.           $endereco   $config->endereco;
  23.           $telefone   $config->telefone;
  24.           $impressora_venda $config->impressora_venda;
  25.           
  26.           $mesa Mesas::find($object->mesa_id);
  27.           
  28.           
  29.           $connector = new WindowsPrintConnector('MOME DA IMPRESSORA NO WINDOWS'); 
  30.           $printer = new Printer($connector);
  31.           $tux EscposImage::load("app/images/brasa_menor.png"false);
  32.           $printer->setJustification(Printer::JUSTIFY_CENTER);
  33.           $printer -> bitImage($tux);
  34.           $printer -> setTextSize(11);
  35.           $printer -> text(" \n");
  36.           $printer -> text(utf8_decode($endereco));
  37.           $printer -> text(" \n");              
  38.           $printer -> text(utf8_decode($telefone));
  39.           $printer -> text(" \n");
  40.           $printer -> text(utf8_decode('CNPJ.: 42.263.161/0001-18'));
  41.           $printer -> text(" \n");              
  42.           $printer -> text("------------------------------------------------");
  43.           $printer -> selectPrintMode(Printer::MODE_FONT_B);
  44.           $printer->setJustification(Printer::JUSTIFY_CENTER);
  45.           $printer -> setTextSize(22);
  46.           $printer -> text('MESA: '.$mesa->numero_mesa);
  47.           $printer->feed(2);
  48.           
  49.           $printer -> selectPrintMode(Printer::MODE_FONT_B);
  50.           $printer->setJustification(Printer::JUSTIFY_CENTER);
  51.           $printer -> setTextSize(21);
  52.           $printer -> text($object->data_formatada);
  53.           $printer->feed(1);
  54.           $printer -> text('EXTRATO PARA SIMPLES CONFERÊNCIA');
  55.           $printer->feed(1);
  56.           $printer->setJustification(Printer::JUSTIFY_RIGHT);
  57.           $printer -> selectPrintMode(Printer::MODE_FONT_A);
  58.           $printer -> text("------------------------------------------------");
  59.           $printer->feed(1);
  60.           $printer->text('QTDE/PRODUTO               PREÇO UN        TOTAL');
  61.           $printer->feed(1);
  62.           $printer->setJustification(Printer::JUSTIFY_RIGHT);
  63.           $printer -> selectPrintMode(Printer::MODE_FONT_A);
  64.           $printer -> text("------------------------------------------------");
  65.           $printer->feed(1);
  66.  
  67.           $items  VendasItens::where('venda_id''='$key)->load();
  68.           
  69.           
  70.           $total 0;
  71.                 
  72.           foreach( $items as $item )
  73.           {
  74.                
  75.                $letras strlen(trim(substr(Produtos::findInTransaction('sgbr'$item->produto_id)->descricao,0,25)));
  76.                $espacos 28-$letras;
  77.                $produto str_pad(substr(Produtos::findInTransaction('sgbr'$item->produto_id)->descricao,0,25),$espacos" ");
  78.                $qtde    =  number_format($item->quantidade,0,',','.');   
  79.        
  80.        
  81.                $preco number_format($item->preco,2,',','.');
  82.                $total_un number_format($item->preco*$item->quantidade,2,',','.');
  83.        
  84.                $printer->setJustification(Printer::JUSTIFY_RIGHT);
  85.                $printer ->selectPrintMode(Printer::MODE_FONT_A);
  86.        
  87.        
  88.                 $printer->text("{$qtde}  {$produto} ({$preco}) --> ({$total_un})");
  89.                 $printer->feed(1);
  90.        
  91.       
  92.                
  93.                
  94.                $total += ($item->preco*$item->quantidade);
  95.           
  96.           }
  97.           $printer->setJustification(Printer::JUSTIFY_RIGHT);
  98.           $printer -> selectPrintMode(Printer::MODE_FONT_A);
  99.           $printer -> text("------------------------------------------------");
  100.           $printer->feed(1);
  101.           
  102.           $taxa       $total*$p_taxa*0.01;
  103.           
  104.           $valor_taxa number_format($total*$p_taxa*0.01,2,',','.');
  105.           $sub_total  number_format($total,2,',','.');
  106.           
  107.           
  108.           if ($cobrartaxa=='S'){
  109.           
  110.              $total_geral  number_format($total+$taxa,2,',','.');
  111.              $taxa_servico number_format($taxa,2,',','.');
  112.             
  113.              $printer->setJustification(Printer::JUSTIFY_RIGHT);
  114.              $printer ->selectPrintMode(Printer::MODE_FONT_B);
  115.              $printer ->setTextSize(21);
  116.              $printer ->text("SUB-TOTAL R$.: {$sub_total}");
  117.              $printer->feed(1);
  118.              $printer ->text("Taxa Serviço.: {$taxa_servico}");
  119.              $printer->feed(1);
  120.              $printer ->text("TOTAL A RECEBER R$.: {$total_geral}");
  121.              $printer->feed(1);
  122.             
  123.           } else { 
  124.           
  125.              $total_geral $sub_total;
  126.              
  127.              $printer->setJustification(Printer::JUSTIFY_RIGHT);
  128.              $printer ->selectPrintMode(Printer::MODE_FONT_B);
  129.              $printer ->setTextSize(21);
  130.              $printer ->text("TOTAL R$.: {$total_geral}");
  131.              $printer->feed(1);
  132.           }
  133.            
  134.           $printer->setJustification(Printer::JUSTIFY_RIGHT);
  135.           $printer -> selectPrintMode(Printer::MODE_FONT_A);
  136.           $printer -> text("------------------------------------------------");
  137.           $printer->feed(1);
  138.           
  139.           $printer->setJustification(Printer::JUSTIFY_LEFT);
  140.           $printer -> selectPrintMode(Printer::MODE_FONT_A);
  141.           $printer ->text("ATENDENTE:  {$atendente}");
  142.           $printer->feed(1);
  143.           $printer->setJustification(Printer::JUSTIFY_RIGHT);
  144.           $printer -> selectPrintMode(Printer::MODE_FONT_A);
  145.           $printer -> text("------------------------------------------------");
  146.           $printer->feed(1);
  147.           $printer->setJustification(Printer::JUSTIFY_CENTER);
  148.           $printer ->selectPrintMode(Printer::MODE_FONT_B);
  149.           $printer ->setTextSize(21);
  150.           $printer ->text("Agradecemos a preferência!");
  151.           $printer->feed(1);
  152.           $printer->setJustification(Printer::JUSTIFY_RIGHT);
  153.           $printer -> selectPrintMode(Printer::MODE_FONT_A);
  154.           $printer -> text("------------------------------------------------");
  155.           $printer->feed(1);
  156.           $printer->setJustification(Printer::JUSTIFY_CENTER);
  157.           $printer ->selectPrintMode(Printer::MODE_FONT_B);
  158.           $printer ->setTextSize(21);
  159.           $printer ->text("****DOCUMENTO NÃO FISCAL****");
  160.           $printer->feed(2);
  161.           $printer -> cut();
  162.           $printer -> close();   
  163.           
  164. ?>