如何静默打印html内容(收据)

时间:2017-01-31 12:27:01

标签: php apache codeigniter kiosk kiosk-mode

我正在使用PHP CodeIgniter开发一个POS系统,我需要在每个交易中打印收据。我可以根据所选产品生成动态收据,并且能够使用iframe打印它们。

我的问题是我需要静默打印这些收据(不在屏幕上提示任何内容)。我在Chrome浏览器中尝试过-kisok-printing,使用Kiosk打开打印对话框,然后使用默认打印机自动打印内容,打印对话框关闭。

我甚至不需要在不对屏幕显示任何效果的情况下显示和打印打印对白。

请给我一个相同的方法。

2 个答案:

答案 0 :(得分:0)

您有几个选择:

  1. 以自然语言编写包装器UI,以便在信息亭上运行,该信息亭拦截收据打印命令并以原生方式执行。
  2. 将打印机连接到网络,让网络服务器为您触发打印到网络打印机,例如使用类似PHP-Printer的内容。
  3. 为此目的安装浏览器插件/扩展程序,例如MeadCo ScriptX(您需要处理客户端缺少插件的情况)。

答案 1 :(得分:0)

I've sold the same issue using https://github.com/mike42/escpos-php for POS printer (it works great with EPSON TM-T20 only pure php:

<?php
/* Call this file 'hello-world.php' */
require __DIR__ . '/vendor/autoload.php';
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\Printer;
$connector = new FilePrintConnector("php://stdout");
$printer = new Printer($connector);
$printer -> text("Hello World!\n");
$printer -> cut();
$printer -> close();

for none POS Printer (if it appear one day you need it) I suggest you try this blog https://www.neodynamic.com/articles/Print-HTML-from-PHP-to-client-printer-without-print-dialog-silently/ notice that I never try it before. I hope this will help you.