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

    Join Date
    Mar 2017
    Posts
    29
    Rep Power
    0

    Question printing a text file by python and thermal printer


    hello friends
    i want to print a text file by a thermal printer(epson TM-T20) and by using python code...
    i am going to use python-escpos or python-printer-escpos module for writing python code...

    i have searched alot in these modules' documents..i found commands for printing a text inside python but i didn't find anything about printing a text file outside of python
    please guide me
    should i convert my text file to a special file type ?
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Posts
    5,835
    Rep Power
    509
    https://pypi.python.org/pypi/python-...r-escpos/0.0.3

    how to print text on one of these printers
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2017
    Posts
    29
    Rep Power
    0
    i saw this module already...but i didn't find any content about printing a file..
  6. #4
  7. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Posts
    5,835
    Rep Power
    509
    Code:
    # python3
    
    from escpos.connections import getUSBPrinter
    
    
    printer = getUSBPrinter()(idVendor=0x1504,
                              idProduct=0x0006
                              inputEndPoint=0x82,
                              outputEndPoint=0x01) # Create the printer object with the connection params
    
    
    
    with open(myfile, 'rt') as inf:
         for line in inf:
         	 printer.text(line)
    [code]Code tags[/code] are essential for python code and Makefiles!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2017
    Posts
    29
    Rep Power
    0

    Thumbs up


    Originally Posted by b49P23TIvg
    Code:
    # python3
    
    from escpos.connections import getUSBPrinter
    
    
    printer = getUSBPrinter()(idVendor=0x1504,
                              idProduct=0x0006
                              inputEndPoint=0x82,
                              outputEndPoint=0x01) # Create the printer object with the connection params
    
    
    
    with open(myfile, 'rt') as inf:
         for line in inf:
         	 printer.text(line)
    thank you very much...

IMN logo majestic logo threadwatch logo seochat tools logo