• <tfoot id='bwi8L'></tfoot>
      <i id='bwi8L'><tr id='bwi8L'><dt id='bwi8L'><q id='bwi8L'><span id='bwi8L'><b id='bwi8L'><form id='bwi8L'><ins id='bwi8L'></ins><ul id='bwi8L'></ul><sub id='bwi8L'></sub></form><legend id='bwi8L'></legend><bdo id='bwi8L'><pre id='bwi8L'><center id='bwi8L'></center></pre></bdo></b><th id='bwi8L'></th></span></q></dt></tr></i><div id='bwi8L'><tfoot id='bwi8L'></tfoot><dl id='bwi8L'><fieldset id='bwi8L'></fieldset></dl></div>
        <bdo id='bwi8L'></bdo><ul id='bwi8L'></ul>

    1. <small id='bwi8L'></small><noframes id='bwi8L'>

      1. <legend id='bwi8L'><style id='bwi8L'><dir id='bwi8L'><q id='bwi8L'></q></dir></style></legend>

        用 PHP 打印到打印机

        时间:2023-10-04
          <tbody id='hkTh9'></tbody>

          <i id='hkTh9'><tr id='hkTh9'><dt id='hkTh9'><q id='hkTh9'><span id='hkTh9'><b id='hkTh9'><form id='hkTh9'><ins id='hkTh9'></ins><ul id='hkTh9'></ul><sub id='hkTh9'></sub></form><legend id='hkTh9'></legend><bdo id='hkTh9'><pre id='hkTh9'><center id='hkTh9'></center></pre></bdo></b><th id='hkTh9'></th></span></q></dt></tr></i><div id='hkTh9'><tfoot id='hkTh9'></tfoot><dl id='hkTh9'><fieldset id='hkTh9'></fieldset></dl></div>
        • <small id='hkTh9'></small><noframes id='hkTh9'>

                • <bdo id='hkTh9'></bdo><ul id='hkTh9'></ul>

                  <tfoot id='hkTh9'></tfoot><legend id='hkTh9'><style id='hkTh9'><dir id='hkTh9'><q id='hkTh9'></q></dir></style></legend>
                  本文介绍了用 PHP 打印到打印机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试设置 CLI PHP 应用程序以将一组网页打印到默认或指定的打印机.我在 Windows 7 机器上,PHP 5.2.11 在 CLI 中运行.为了测试打印功能,我加载了 PHP_printer.dll 并打印到 Onenote,这是一个打印到文件选项,使用 PRINTER_ENUM_LOCAL 中给出的确切打印机名称.
                  更新:这是最新的代码:

                  I'm trying to set up a CLI PHP application to print a set of web pages to a default or specified printer. I'm on a Windows 7 machine with PHP 5.2.11 running in a CLI. To test the print functionality I've loaded PHP_printer.dll and I'm printing to Onenote, a print to file option, using the exact printer name given in PRINTER_ENUM_LOCAL.
                  Update: Here's the latest code:

                  $handle = printer_open("Send To OneNote 2010");
                  printer_start_doc($handle, "My Document");
                  printer_start_page($handle);
                  
                  $filename='index.html';
                  $fhandle=fopen($filename, 'r');
                  $contents = fread($fhandle, filesize($filename));
                  fclose($fhandle);
                  
                  printer_set_option($handle, PRINTER_MODE, "RAW");
                  printer_write($handle,$contents);
                  
                  printer_end_page($handle);
                  printer_end_doc($handle);
                  printer_close($handle);
                  

                  我已获得此代码以将空白页打印到正确的打印机,但我无法打印传递给printer_write 的字符串.我确认 $contents 正确填充了我的测试 html 文件的内容.无论我提供什么作为第二个 arg(要打印的字符串),我都会得到一个空白页.有什么我遗漏的东西至少可以让我在页面上打印一些文本吗?

                  I've gotten this code to print a blank page to the correct printer, but I'm unable to print the strings I pass to printer_write. I confirmed that $contents is properly filled with the contents of my test html file. No matter what I provide as the second arg (string to be printed) I get a blank page. Is there something I'm missing to at least allow me to print some text onto a page?

                  或者有没有更好的方法来做到这一点(使用 PHP/javascript 文件)?我想要做的是通过 CLI 应用程序打印出现的网页(包括 CSS),该网站是用 PHP 编写的,我试图将复杂性降至最低.如果有更好的方法来打印这些(显然转换为 PDF 和打印是一个选项)我是开放的,但听起来这是 PHP 中最简单/事实上的方法.

                  Alternately is there a better way to do this (using PHP/javascript files)? What I am trying to do is print web pages as they appear (CSS included) via a CLI app, the web siteis written in PHP and I'm trying to minimize complexity. If there is a better way to print these (converting to PDF and printing is an option apparently) I'm open but it sounded like this was the simplest/de facto method in PHP.

                  推荐答案

                  我对printer.dll 搞了很长时间并且厌烦了.

                  i messed around with printer.dll for ages and got sick of it.

                  不确定它是否有多大用处,但我购买了此应用程序http://www.coolutils.com/TotalPDFPrinter

                  not sure if its much use, but i purchased this application http://www.coolutils.com/TotalPDFPrinter

                  它让我从 php 的 cmd 行打印 pdf 文件,这对我来说效果很好,但它确实有一个弹出屏幕,只有在您购买服务器版本时才能摆脱(如果您需要apache 作为服务运行).显然非弹出版本要贵得多.

                  and it lets me print pdf files from the cmd line from php, which worked well for me, but it does have a popup screen which you can only get rid of if you purchase the server version (which you will need if your apache is running as a service). obviously the non-popup version is way more expensive.

                  我挣扎的一件事是获取可用的打印机列表,所以我用 C# 编写了这个小应用程序,它以纯文本形式输出打印机列表,然后使用 php 调用它并将它们放入下拉列表在我的网络表单上.

                  one thing i struggled with, was getting a list of printers available, so i wrote this little app in C# that spits out a list of printers as plain text, and then use php to call that and put them into a drop list on my web forms.

                  using System;
                  using System.Collections.Generic;
                  using System.Text;
                  using System.Drawing.Printing;
                  
                  namespace printerlist
                  {
                      class Program
                      {
                          static void Main(string[] args)
                          {
                              foreach (String printer in PrinterSettings.InstalledPrinters)
                              {
                                  Console.WriteLine(printer.ToString());
                              }
                          }
                      }
                  }
                  

                  这篇关于用 PHP 打印到打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:从 PHP 应用程序通过网络打印 下一篇:POS:让网站直接打印到定义的本地打印机

                  相关文章

                  最新文章

                  1. <small id='1JiZ0'></small><noframes id='1JiZ0'>

                  2. <tfoot id='1JiZ0'></tfoot>
                    <i id='1JiZ0'><tr id='1JiZ0'><dt id='1JiZ0'><q id='1JiZ0'><span id='1JiZ0'><b id='1JiZ0'><form id='1JiZ0'><ins id='1JiZ0'></ins><ul id='1JiZ0'></ul><sub id='1JiZ0'></sub></form><legend id='1JiZ0'></legend><bdo id='1JiZ0'><pre id='1JiZ0'><center id='1JiZ0'></center></pre></bdo></b><th id='1JiZ0'></th></span></q></dt></tr></i><div id='1JiZ0'><tfoot id='1JiZ0'></tfoot><dl id='1JiZ0'><fieldset id='1JiZ0'></fieldset></dl></div>
                    <legend id='1JiZ0'><style id='1JiZ0'><dir id='1JiZ0'><q id='1JiZ0'></q></dir></style></legend>
                      <bdo id='1JiZ0'></bdo><ul id='1JiZ0'></ul>