Skip to content Skip to sidebar Skip to footer

Printing To Windows Printer With Python Or Shell Command

I'm tryin to script an annoying task that involves fetching, handling and printing loads of scanned docs - jpeg or pdf. I don't succeed in accessing the printer from python or from

Solution 1:

I used this for a rtf (just an idea) :

subprocess.call(['loffice', '-pt', 'LaserJet', file])

I am using LibreOffice. it can print in a batch mode.

Solution 2:

with a default pdf viewer assigned to the system you can do

import win32api
 fname="C:\\somePDF.pdf"
 win32api.ShellExecute(0, "print", fname, None,  ".",  0)

note that this will only work on windows and will not work with all pdf viewers but it should be good with acrobat and Foxit and several other major ones.

Post a Comment for "Printing To Windows Printer With Python Or Shell Command"