Printing a text file using Python
Robin Lee
robin_lee55 at hotmail.com
Mon Aug 11 05:19:43 EDT 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/20080811/fd1214b5/attachment.html>
More information about the Python-list
mailing list