[python-win32] printing landscape in Windows

Andreas Holtz A.Holtz at gmx.net
Mon Jul 13 23:40:00 CEST 2015


Think about using a batch print tool like
http://www.verypdf.com/app/pdf-print-cmd/
or
http://www.doc2prn.com/

I used the first one and implemented a Python script to create the command (it prints more than PDF).

Some professional printer offer a webserver where you can upload the files. Check this, too.

As you only want to print text files, you can use AutoIt to automate Notepad++ or the like.
Set the default setting of the printer to landscape manually before.

Regards

Andreas

Hans Becker schrieb am 10.06.2015 um 20:48:
> Just about a month ago I started reading Learning Python by Mark Lutz.
> It's a new paradigm for me. I have a whole bunch of old mainframe files
> with carriage control characters as the 1st character in each line.
> Well, a got a very simple script working except I need to be able to
> print landscape on my pc printer. Does anyone by chance have sample code I
> could cut and paste to print landscape? I'm running Windows 7 Pro and
> Python 2.7
>  
>  
> #prt1a is a copy of prt11
>  
> import os, sys, tempfile
> import win32api, win32print
>  
> printer_name = win32print.GetDefaultPrinter ()
> hPrinter = win32print.OpenPrinter (printer_name)
>  
> hJob = win32print.StartDocPrinter (hPrinter, 1, ('alfie', None, "RAW"))
> win32print.StartPagePrinter (hPrinter)
>  
> for line in open('alf1'):
>     cc = line[0]
>     line = line[1:]
>     line = line.rstrip()
>    
>     if   cc == '1': line = '\f' + line
>     elif cc == ' ': line = '\n' + line
>     elif cc == '0': line = '\n\n' + line
>     elif cc == '-': line = '\n\n\n' + line
>  
>     line = line + '\r'   # takes care of the overprinting
>     win32print.WritePrinter(hPrinter, line)
>  
> win32print.WritePrinter(hPrinter,"\f")
> win32print.EndPagePrinter (hPrinter)
> win32print.EndDocPrinter (hPrinter)
> win32print.ClosePrinter (hPrinter)
>  
>  
> my test data 'alf1':
>  
> 1                 QWDDNNNDNDN
> ++2                 /111111111
> ++2a                XXXXXXXX11
> 3                ZDDDDNDNDNNN
> ++4               #/1111111111
> ++4a              #XXXXXXXXX11
> ++4 b             #WWWWWWWWWW1
> 5   MMMMMMNMMMMMMMMNMNNNNMNNNM
> ++6  IIIIII1IIIIIIII1I1111I111I
> ++6a IIIIII1IIIIIIII1I1111I111I
> 7   NNMNNNNNNNNNNNNNNNNNNNNNMM
> ++8  11I111111111111111111111II
> 9   ..........................
> 10  --------------------------
> 11  ;;;;;;;;
>  
>  
> Thanks
>  
> Hans Becker
> 
> 
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> https://mail.python.org/mailman/listinfo/python-win32
> 


More information about the python-win32 mailing list