Printing a text file using Python

Serge Guay serge at theguays.com
Fri Oct 24 21:44:57 EDT 2003


I have been trying to print a text file to my printer but the most I have
been able to do is print one line. I have been using the following commands.

        dc = win32ui.CreateDC()
 	  dc.CreatePrinterDC()
        dc.SetMapMode(4)        # This is UI_MM_LOENGLISH
        # With this map mode, 12 points is 12*100/72 units = 16
        font = win32ui.CreateFont({'name' : 'Arial', 'height' : 16})
        dc.SelectObject(font)
        f=open("./Reports/Report.txt","r")
        memory=f.read()
        f.close
        memory.split('\n')
        dc.StartDoc("./Reports/Report.txt")
        dc.StartPage()
        dc.TextOut(10,10,memory)
        dc.EndPage()
        dc.EndDoc()

Can anyone tell me how I need to change this so it will print out the entire
file instead of just one line.

Thanks in advance...
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.524 / Virus Database: 321 - Release Date: 10/6/2003






More information about the Python-list mailing list