Print file via file association using os.system or subprocess? (Windows)

python at bdurham.com python at bdurham.com
Sun Jul 18 21:49:27 EDT 2010


Hi Mark,

> You probably want to use the windows ShellExec function with a 'print' verb.

Thanks Mark! And cheers for the great win32api library!!

I've included a link[1] on how to do this for anyone searching the
archives.

Malcolm

[1] Print via ShellExecute (prints to the user's default printer)
http://timgolden.me.uk/python/win32_how_do_i/print.html#shellexecute

Example:

win32api.ShellExecute( 0, 'print', fileName, None, '.', 0 )

<snipped> 
Under Windows: Is there a way to print a file using the file's file
extension association using either the os.system or subprocess modules
(vs. win32 extensions)?

Use case: print PDF or Office documents to default printer without
having to distribute win32 extensions.
</snipped>



More information about the Python-list mailing list