我正在运行这个问题中显示的Python代码,以便通过特定的托盘打印文件:Change printer tray with pywin32
IIS服务器上的代码为'打印.py,并将通过PHP文件调用打印.php,以便客户端可以连接到它并通过浏览器自动打印。你知道吗
两者都是打印.py'和'打印.php'在IIS服务器上运行并打印成功。你知道吗
在浏览器中运行时,什么都没有发生。我相信这是由于权限问题,但不确定这是否是由于Python、PHP、IIS或打印机设置。。。你知道吗
我在链接问题中显示的Python中添加了以下行:
import cgitb
import cgi
cgitb.enable()
这将在浏览器中显示以下内容:
A problem occurred in a Python script. Here is the sequence of function
calls leading up to the error, in the order they occurred.
20 # Get a handle for the default printer
21 device_name = "I_put_the_printer_name_here"
=> 22 handle = win32print.OpenPrinter(device_name)
23
24 # Get the default properties for the printer
handle undefined, win32print = <module 'win32print' from
'C:\Python27\lib\site- packages\win32\win32print.pyd'>,
win32print.OpenPrinter = <built-in function OpenPrinter>,
device_name = 'I_put_the_printer_name_here'
<class 'pywintypes.error'>: (5, 'OpenPrinter', 'Access is denied.')
args = (5, 'OpenPrinter', 'Access is denied.')
funcname = 'OpenPrinter'
message = ''
strerror = 'Access is denied.'
winerror = 5
这是你的打印.php'访问'打印.py':
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$output = shell_exec("C:\Python27\python.exe print.py");
echo $output;
?>
如前所述,在服务器上运行时,一切正常,打印效果良好。当通过浏览器访问时,什么都不会发生。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐