PHP打印到服务器端打印机 [英] PHP to print to a server side printer

查看:495
本文介绍了PHP打印到服务器端打印机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PHP打印到服务器端打印机。我已经找到类似的示例代码,大多数都使用相同的API的功能来完成此任务。当我在我的服务器上运行它来测试代码时,它就是说PHP致命错误:调用未定义的函数printer_open()。所以我发现这个打印机功能的 php_printer.DLL的至少有三个不同的版本,并单独尝试。我做了一些更多的研究,并研究apache服务器错误日志发现这个警告

I am trying to use PHP to print to a server side printer. I have found similar example code that mostly all use the same API’s functions in order to do this task. When I ran it on my server to test the code it was saying "PHP Fatal error: Call to undefined function printer_open()". So I found at least three different versions of the php_printer.DLL’s for this printer function and tried them all separately . I did some more research and looking into the apache server error log found this warning

PHP警告:PHP启动:无法加载动态库'ext \php_printer .dll' - 无法找到指定的模块。\r\\\
在第0行的未知状态

从这里发现一些 Bing搜索结果表示,当apache启动时,它不加载的原因是因为它取决于其他库。如果这是真的,我还没有找到哪些库DLL是这些,哪里可以得到它们。这是我需要帮助,首先基本知道是否不依赖,那么为什么要抛出PHP警告或需要什么库?

From this found some Bing search results that said that the reason it is not loading when apache starts up is because it is depend on other libraries. If this is true I have not as yet been able to find which library DLL’s these are and where to get them. This is what I need help with first to basically know if it is not depended then why is the PHP warning being thrown or what library’s do I need.

感谢任何帮助

zac

我正在运行wampserver2.2

I am running a wampserver2.2

Apache 2.4.2

Apache 2.4.2

PHP 5.4.3

PHP 5.4.3

操作系统:Windows 7 64位

OS : windows 7 64 bit

添加到php.ini文件

Added to the php.ini file

extension = php_printer.dll

extension=php_printer.dll

,php日志中没有错误

and no errors in the php log

也是我每次更改php.ini文件或者当我将一个新的DLL放在* ext *目录
我甚至把路径放在wamp DLL的... \ext\在Windows的环境变量中,作为黑暗中的一个镜头。

also I did restarted the server each time I change the php.ini file or when I put a new DLL in the *ext* directory I even put the path to the wamp DLL’s "...\ext\" in the environment variables for windows, as a shot in the dark .

示例代码

<?php
/* get the sample text */
$lipsum = "test print";//file_get_contents('lipsum.txt');
phpinfo();

/* open a connection to the printer */
$printer = printer_open("Microsoft XPS Document Writer");

/* write the text to the print job */
printer_write($printer, $lipsum);

/* close the connection */
printer_close($printer);
?>

3/19/2015编辑

3/19/2015 edited

我发现这个网站连同一个稍微不同的错误消息从php错误日志。
基本上是下面的链接说错误发生是因为PHP_printer.dll符合不同的visual studio c ++版本,因此需要重新编译。它给了我大部分的步骤,我仍然在努力让它工作

I found this site along with a slightly different error message from the php error log. basically the below link said the error happened because the PHP_printer.dll is complied with a different visual studio c++ version and therefore need to be recompiled. it gives the steps for the most part I still am tring to get it to work

https://community.apachefriends.org/f/viewtopic.php?t=53348&p=204590

Php错误:


[2015年3月18日22:55:56 UTC] PHP警告: PHP启动:打印机:无法
初始化模块模块编译API = 20121212 PHP

编译与模块API = 20100525这些选项需要匹配
未知的行0

[18-Mar-2015 22:55:56 UTC] PHP Warning: PHP Startup: printer: Unable to initialize module Module compiled with module API=20121212 PHP
compiled with module API=20100525 These options need to match in Unknown on line 0


推荐答案

如果您找不到解决方案....

In case you couldn't found a solution yet....

首先检查 phpinfo()在使用线程安全性的wmap服务器版本中是否启用。 ctrl + F phpinfo()中为线程安全。

First of all check in phpinfo() that in the version of wmap server you are using thread safety is enabled or not. Just ctrl+F in the phpinfo() for "thread safety".

您正在使用的版本中启用了线程安全性。那么你必须下载ts(线程安全)版本的 php_printer.dll ,你可以在这里找到。

Probably thread safety is enabled in the version you are using. Then you have to download the ts(thread safe) version of the php_printer.dll which you can find here....

http://windows.php.net/下载/ pecl / snaps / printer / 0.1.0-dev /

根据您的系统要求下载特定文件(操作系统和其他),并将其复制wamp的扩展目录。然后只需在 php.ini 文件中启用扩展名,如

download specific file according to your system requirement (OS and others) and copy it in the extension directory of the wamp. Then just enable the extension in the php.ini file like

extension=php_printer.dll

只要将这行添加到ini文件中,如果已经没有,那将不会

just add this line in the ini file if already not there and there will be no ; at the beginning.

希望帮助...

这篇关于PHP打印到服务器端打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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