How do i print to a printer using python?

Frank Buss fb at
Thu Sep 5 13:45:52 CEST 2002

"G. Willoughby" <never at> wrote:

> I would really like to know how to do this too, basically i want to
> print to a standard bubblejet print (non postscript) from a Tkinter
> Text widget, any ideas?

Perhaps you can draw a PDF file with Reportlab ( 
and printing it. Because you are using Outlook Express, I assume you need 
it for Windows. An example:

from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4
c = canvas.Canvas('c:\\tmp\\test.pdf', pagesize=A4, bottomup=0)
c.setFont('Helvetica', 14)
c.drawString(10, 20, 'Hello World!')

If you want direct printing, without user interaction and you know the 
path of the Acrobat Reader, you can use this line:

system('"C:\\Programme\\Adobe\\Acrobat 5.0\\Reader\\AcroRd32.exe" /p /h c:

Perhaps it's easier with the ShellExecute command, because then you don't 
need to know the path of AcroRd32.exe, but then you need this, if you 
don't have ActiveState Python installed:

If you just want to show the user the page and let the user decide to 
print or close the document, this lines are sufficient:

from os import startfile

Frank Buß, fb at,

More information about the Python-list mailing list