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 Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


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