Hello everyone, I am trying to print a string (not a file) with win32print api and I'm using Tim Golden's <http://timgolden.me.uk/python/win32_how_do_i/print.html> third block of code (pasted below) as a testing example but without success. There is just no errors and the printer spool show the file rapidly and then nothing occurs. I could print using the ShellExecute but that's not what I need, since it prints files (and file names to pages, which I also don't want). Here is Tim Golden's snippet I'm using to test:
import os, sys import win32print printer_name = win32print.GetDefaultPrinter () # # raw_data could equally be raw PCL/PS read from # some print-to-file operation # if sys.version_info >= (3,): raw_data = bytes ("This is a test", "utf-8") else: raw_data = "This is a test" hPrinter = win32print.OpenPrinter (printer_name) try: hJob = win32print.StartDocPrinter (hPrinter, 1, ("test of raw data", None, "RAW")) try: win32print.StartPagePrinter (hPrinter) win32print.WritePrinter (hPrinter, raw_data) win32print.EndPagePrinter (hPrinter) finally: win32print.EndDocPrinter (hPrinter) finally: win32print.ClosePrinter (hPrinter) Thanks! Marcelo.
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32