如何在Python中将作业发送到网络打印机

huangapple go评论81阅读模式
英文:

How to send a job to a network printer in Python

问题

如何在Python中将文件/作业发送到网络打印机。
我尝试了以下代码,但这仅用于发送文本,但我想要发送PDF/文件到打印机。

from escpos.connections import getNetworkPrinter    
printer = getNetworkPrinter()(host='192.168.0.20', port=9100)

printer.text("Hello World")
printer.lf()
英文:

all How i can send file/job to a network printer in Python.
I tried the following code but this is used to send only the text, but i want to send pdf/file to the printer.

    from escpos.connections import getNetworkPrinter    
    printer = getNetworkPrinter()(host='192.168.0.20', port=9100)
    
    printer.text("Hello World")
    printer.lf()

答案1

得分: 1

我相信你无法打印PDF,但可以打印图像。将你的PDF转换为图像,然后打印。请参阅escpos文档pdf2image

英文:

I believe you can’t print pdf but images. Convert your pdf to image and print that.
See the docs for escpos and pdf2image

huangapple
  • 本文由 发表于 2020年1月6日 22:15:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/59613653.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定