调用未定义的函数 printer_open() [英] Call to undefined function printer_open()

查看:213
本文介绍了调用未定义的函数 printer_open()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过此代码连接到另一台机器上的打印机

I am trying to connect to my printer which is on another machine through this code

     $handle = printer_open("\\\\xxx.xxx.xxx.xxx\\Canon MF4320-4350");
     if($handle)
     echo "connected";
     else
     echo "not connected";     

并得到错误

    Fatal error: Call to undefined function printer_open() in C:\wamp\www\print\index.php on line 3

我已经安装了 php_printer.dll,但它没有在 phpinfo() 下显示.使用 PHP 5.3.0 版

I have installed the php_printer.dll but it is not showing it under phpinfo(). Using PHP version 5.3.0

如何连接到打印机并使我的 printer_open() 方法工作?

how can i connect to the printer and make my printer_open() method work??

推荐答案

如果您在 WAMP 中使用 PHP 5.3/5.4/5.5,这里是您设置打印机的方法.

If you are using PHP 5.3/ 5.4/ 5.5 in WAMP, here is how you setup printer.

  1. 转到此链接:http://windows.php.net/downloads/pecl/snaps/printer/0.1.0-dev/
  2. 下载您的版本的 zip.首先尝试使用 ts.如果它不起作用,请尝试 nts.
  3. 解压并复制 php_printer.dll 文件.粘贴在这里: C:\wamp\bin\php(phpyourversion)\ext .注意:(phpyourversion) 将类似于 php5.5.12,具体取决于您的版本.
  4. 找到加载的 php.ini 文件.使用 phpinfo 或 Wamp 菜单找到它.在线寻求更多帮助.
  5. 将其粘贴到文件末尾:extension=php_printer.dll
  6. 重启服务器.
  7. 使用以下代码创建一个文件并进行测试:

  1. Go to this link:http://windows.php.net/downloads/pecl/snaps/printer/0.1.0-dev/
  2. Download the zip for your version. First try with ts. If it does not work, try nts.
  3. Unzip and copy the php_printer.dll file. Paste here: C:\wamp\bin\php(phpyourversion)\ext . Note: (phpyourversion) will be like php5.5.12 depending on your version.
  4. Find the loaded php.ini file. Use phpinfo or Wamp menu to find it. Look online for more help.
  5. Paste this at the end of the file: extension=php_printer.dll
  6. Restart server.
  7. Create a file with the following code and test it:

<代码>$printer_name = "您的打印机名称完全一样";$handle = printer_open($printer_name);printer_start_doc($handle, "我的文档");打印机开始页面($句柄);$font = printer_create_font("Arial", 100, 100, 400, false, false, false, 0);打印机选择字体($handle, $font);printer_draw_text($handle, '这句话应该打印出来.', 100, 400);printer_delete_font($font);打印机结束页面($句柄);printer_end_doc($handle);printer_close($handle);

如果上述方法不起作用,请尝试使用第 2 步中提到的 php_printer.dll 文件的 nts 版本.记得删除之前的文件后重启服务器,粘贴新文件.

If the above does not work, try with nts version of the php_printer.dll file as mentioned in step two. remember to restart server after deleting the previous file, pasting the new file.

这篇关于调用未定义的函数 printer_open()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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