使用PHP打印到网络打印机

使用PHP打印到网络打印机

问题描述:

是否可以使用LPR或类似工具通过PHP直接打印到网络打印机?

is it possible to print directly to a network printer with PHP using LPR or something similar?

任何指针?

谢谢.

当然可以.如果您使用的是Linux,请使用LPR.

exec("lpr -P 'printer' -r 'filename.txt'");

有关LPR命令的更多信息. 查看LPR文档.您可以轻松地从PHP中显示打印队列和其他内容.

More on LPR commands. Take a look into LPR docs. You can easily show the print-queue and more from PHP.

如果您使用的是Windows,请使用打印

exec("print /d:LPT2: C:\filename.txt");

更多有关印刷语法的信息
或查看本指南对命令行打印有更深入的说明.

More on print syntax
Or take a look into this guide that has a deeper explanation of command-line printing.