Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I print to the OS's default printer in Python 3 (cross platform)?

I have a Python 3 script that is going to be doing some regex substitution on some Rich Text Files (rtf) and I would like to be able to print out a whole directory's files on Windows, Linux, and Mac.

Is there a way to print to the OS's default printer so that it works in all platforms?

like image 539
Magwich Avatar asked Feb 23 '10 05:02

Magwich


1 Answers

There is no cross-platform way. On Linux and OS X you can invoke lpr(1) via subprocess and CUPS will handle the document conversion as best as possible, but Windows is trickier.

like image 73
Ignacio Vazquez-Abrams Avatar answered Sep 28 '22 01:09

Ignacio Vazquez-Abrams