Re: [python-win32] win32 printer

2017-11-28 Thread Tim Roberts
Richard Peeters wrote:
>  
> 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.

It depends on your printer.  Your script works fine on my Brother laser
printer, but many laser printers don't understand raw text.  If your
printer is native Postscript, for instance, it will throw away your raw
input, because that's not a Postscript program.  Some of the cheapest
laser printers don't have any fonts at all -- they rely on a Windows
driver to turn the text into a big bitmap.  Same for the thermal label
printers.  What printer are you using?


> BTW is there a simple method to just print text (as lprint in basic)?

LPRINT was created when the computing world was a very different place. 
It relies on DOS and BIOS calls to send text to the default printer, but
that's default in the BIOS sense, meaning a parallel printer hooked up
to a parallel port on your computer.  If you don't have a parallel port
printer, then LPRINT doesn't work, either.  If you do have a parallel
port printer, you can simulate LPRINT by opening the special file "PRN"
or "LPT1" and writing to it:

    lpr = open("PRN","w")
    lpr.write( "Hello, world!" )

If you're just trying to do logging to a printer, that's tedious but not
terribly difficult in Windows.  You just have to maintain your Y
position, do TextOut calls, and end the page when it is full.  It's
usually way easier to log to a file and print it afterward using
something like Notepad.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

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


Re: [python-win32] win32 printer

2017-11-28 Thread Bob Hood
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


[python-win32] win32 printer

2017-11-28 Thread Richard Peeters
 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