Printing a text file using Python

Robin Lee robin_lee55 at hotmail.com
Sun Jun 1 20:25:59 CEST 2008


Serge:
in your code i believe that you did one read of your whole input file, and then you emitted that to the dc with textout. textout's use  is actually (x,y,string).
hence one line got printed (actually the whole file got printed but truncated!!!!)
you will have to detect all the end of lines and loop a whole lot of dc.textouts

Robin

your code:

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()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080601/2ef4d841/attachment.html>


More information about the Python-list mailing list