开发者

Python access remote printer over socket connection

Have been asked to print to a remote printer via a socket connection, and struggling with how to approach this. I'm already passing data back and forth to a computer on the same network (also via a socket connection), and generating a PDF and/or HTML file with it when necessary. The idea is for me to send that file from the web server to the local printer and print it without any action by the remote user.

I looked into some print libraries and an IPP/CUPS library, but I'm not sure if that code could live within my web app, or if i开发者_如何转开发t would have to live on a print server accessible by my web app that also can communicate with the printer (or something else - I'm really fumbling in the dark).

a) Does this sound plausible?

b) If so, can I control the printer entirely via the socket connection using code that lives on my web server, or will I need to write an application that lives on the client's machine (or network)?

Very unfamiliar working with hardware, so please forgive anything that sounds naive.


I am not sure that this is a good idea.

If I understand the question correctly, this is about printing from a web application. I suggest the users simply use the browser's built-in print function for printing the generated HTML (or the PDF reader's in the case of PDFs).

UPDATE

If you need to automatically print from your web application, I suggest you do the following in the web app:

  1. Generate PDFs on disk
  2. Shell out to lp: subprocess.Popen(['lp', '-d', printername, filename])

The remote printers should be set up in CUPS on the web server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜