I don't know specifically what is wrong with your script, but I wanted to chime in here and confirm that it also failed to print anything for me.  No error messages, nothing in the printer queue, and nothing printed.

On 11/28/2017 10:19 AM, Richard Peeters wrote:
 Hello,
I'm new to Python and this list.
> I installed pypiwin32 ,
and demo runs without errors.... but nothing is printing. I checked and
> nothing in cue
> Os is windows7.
> BTW is there a simple method to just print text (as lprint in basic)?

> tks Richard

> code:
> ----------------------------------
> #printer
> import os, sys
> import win32print
> printer_name = win32print.GetDefaultPrinter ()
> print(printer_name)
> #
> # 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)
> print(hPrinter)
> 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)


_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to