自动打开 PDF 文件的打印机对话框 [英] Open Printer Dialog for PDF file Automatically

查看:28
本文介绍了自动打开 PDF 文件的打印机对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有多种方法可以将 PDF 打印到与服务器位于同一网络的网络打印机,但这对我没有帮助,因为服务器是远程的.在我的情况下,用户单击打印标签"的链接,然后生成并输出为其设置格式的 PDF 文件.我目前将文件输出流式传输"到浏览器,以便 Adob​​e Reader 使用以下代码自动打开它:

I know that there are ways to print a PDF to a network printer located on the same network as the server, but that does not help me as the server is remote. In my situation a user clicks a link to "print labels" which then generates and outputs a PDF file formatted for them. I currently "stream" the file output to the browser such that Adobe Reader automatically opens it using the following code:

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-type: application/pdf");
header('Content-Disposition: attachment; filename="labels.pdf"');
readfile($ServerPathToFile);

还有什么我可以添加到这个代码中的东西,它会自动触发打印对话框打开,这样他们只需要点击打印?在这种情况下,Google CloudPrint 不是一种选择,其他需要在用户端进行特殊设置"的东西也不是一种选择……因为这将被各种用户使用.

Is there something else I can add to this code that will automatically trigger the print dialogue box to open so that they only have to click print? In this case, Google CloudPrint is not an option, nor are other things that require "special setup" on the user end...as this will be used by a variety of users.

推荐答案

您可以将 PDF 输出到同一域上的子窗口(