如何将外部文件的内容发送到打印机? [英] How to send the content of an external file to printer?

查看:227
本文介绍了如何将外部文件的内容发送到打印机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过PHP脚本打印(打印机,而不是屏幕)文件的内容.

I want to print (printer, not screen) the content of a file via a PHP script.

我该怎么做?

推荐答案

更新

php无法轻松访问硬件.通常不认为这是可能的".

Update

php cannot easily access hardware. This is generally not considered "possible."

请参阅:

  • SO "how to "print" to paper"
  • How to print directly to printer

但是,如第一个链接所示,这通常是使用Javascript完成的.您可以采用类似于第一个链接上显示的方法的方式输出Javascript,以强制浏览器显示打印对话框.

However, as the first link shows, this is usually done with Javascript. You can output Javascript in a way similar to the methods shown on the first link to force the browser to show the print dialog box.

您可以使用 file_get_contents 将文件打印到变量或输出流.

You can use file_get_contents to print files into a variable or to the output stream.

$filecontents = file_get_contents("myfilename.txt");
print $filecontents;

您还可以包括文件到您的PHP解释中.

You can also include files into your PHP interpretation.

这篇关于如何将外部文件的内容发送到打印机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆