#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    13
    Rep Power
    0

    Print to line printer


    Re: PyWin 2.7.3

    2 questions:

    #1
    How do I print a .txt file to the line printer?

    #2
    I have 3 .txt files that I want to print to the line printer.

    All 3 files will fit on one page. How do I concatenate these files to print on 1 page?
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,854
    Rep Power
    481
    Load the files into microsoft word and click print?

    Use the DOS print command?

    untested program to concatenate files named on the command line, includes a one line file name separator.

    Code:
    #use:  A:> python thisfile.py a.txt b.txt 3.txt
    import sys
    
    for name in sys.argv[1:]:
        print('{} {}'.format('*'*20,name))
        with open(name) as inf:
            sys.stdout.write(inf.read())
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    491
    Rep Power
    33
    In Linux you can use cat
    cat chapter01 chapter02 chapter03 > book
    and lpr prints
    cat chapter01 chapter02 chapter03 > lpr (assumes you only have one printer)

    If you prefer to use Python, this is a tutorial on reading and writing files.
    Last edited by dwblas; February 19th, 2013 at 10:51 AM.

IMN logo majestic logo threadwatch logo seochat tools logo