pywintypes.error:(31,31,' Shellexecute',''当使用IP/URL用于路径时,已连接到系统上的设备无法正常工作。')

发布于 2025-01-27 07:29:38 字数 670 浏览 1 评论 0原文

嗨,所以我有一个代码,它应该在其中打印出PDF文档的硬拷贝。 问题是,当我使用IP/URL设置路径时,我会说错了。

def printInvoice(inv_id):
    _filepath = "http://192.168.0.72:8000/AR/invoice/"+inv_id+".pdf"    
    print(_filepath)
    printTheFile(_filepath)

def printTheFile(_file):
    currentprinter = win32print.GetDefaultPrinter()
    win32api.ShellExecute(0, 'print', _file, None, ".", 0)
    time.sleep(1)
    os.system("TASKKILL /F /IM Acrobat.exe")

inv_id = "INV2204-001"
printInvoice(inv_id)

如果我设置了直接从脚本文件夹中打印出来的路径,例如“ ar \\发票”它可以正常工作

,我可以通过使用python -m http.server提供该文件夹。,它也可以在浏览器上访问。

目的是使其能够在多个设备上使用,并通过一种存储文档的设备在Internet上打印PDF。

Hi so i have a code where it supposed to print out hardcopy of a pdf documents.
Issue is i got said error when trying to print it when i set the path using ip/url.

def printInvoice(inv_id):
    _filepath = "http://192.168.0.72:8000/AR/invoice/"+inv_id+".pdf"    
    print(_filepath)
    printTheFile(_filepath)

def printTheFile(_file):
    currentprinter = win32print.GetDefaultPrinter()
    win32api.ShellExecute(0, 'print', _file, None, ".", 0)
    time.sleep(1)
    os.system("TASKKILL /F /IM Acrobat.exe")

inv_id = "INV2204-001"
printInvoice(inv_id)

If i set the path to just print it out directly from the script folder like "AR\\invoice" it works fine

Anyway, i make the folder available by using python -m http.server which makes it also available to be access on browser.

The goal is to make it able to work on multiple devices and print the pdf over the internet from one device that stores the docs.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文