Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gmmastros on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

print text file with python

Status
Not open for further replies.

beveronic

Technical User
Dec 17, 2004
10
0
0
DE
Hi,
I have a question about printing. I use the following script for printing in windows:


import win32print
printer_name = win32print.GetDefaultPrinter ()
hPrinter = win32print.OpenPrinter (printer_name)
hJob = win32print.StartDocPrinter (hPrinter, 1, ("test of raw data", None, "RAW"))
win32print.WritePrinter (hPrinter, open("C:\\test.txt",'rt').read())
win32print.EndDocPrinter (hPrinter)
win32print.ClosePrinter (hPrinter)

My lines start on new lines but the string starts where the string for the above line ended.Something like this:
test
test
test
test

Thanks for any suggestions.
Vero
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top