php 服务器打印,PHP服务器端打印Ubuntu服务器

如果CUPS配置正确,从shell打印PDF就像这样简单

lpr myfile.pdf

因此,一旦将PDF写入临时文件,就可以使用任何可用的PHP函数来执行该shell命令:exec(),shell_exec(),system()

您甚至可以在不编写临时文件的情况下执行此操作,并通过STDIN将数据直接提供给lpr(尝试cat myfile.pdf | lpr作为shell上的示例).

如果使用proc_open()运行数据,则可以使用PHP将数据提供给程序的STDIN. PHP Manual的第一个例子可以适用于这样的事情:

$descriptorspec = array(

0 => array("pipe", "r"), // stdin is a pipe that the child will read from

);

$process = proc_open('lpr', $descriptorspec, $pipes);

if (is_resource($process)) {

// $pipes now looks like this:

// 0 => writeable handle connected to child stdin

// 1 => readable handle connected to child stdout

// Any error output will be appended to /tmp/error-output.txt

fwrite($pipes[0], $pdf_data);

fclose($pipes[0]);

}

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值