Python Forum
POS receipt print cannot make paper cut using python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
POS receipt print cannot make paper cut using python
#1
Problem

We are working on a bigger project where we need to make a POS receipt print. We are able to make a print through the browser but the problem is that we cannot make a cut or a partial cut.

Win32 API

We have tried with Win32 API which work as well but we cannot find a command telling the receipt printer to "cut".

We have tried the following with win32:

from win32 import win32api
import win32print
txt = " Hello test ".encode()
p = win32print.OpenPrinter("EPSON TM-T20II Receipt")
job = win32print.StartDocPrinter (p, 1, ("test of raw data", None, "RAW"))
win32print.StartPagePrinter (p)
win32print.WritePrinter (p, txt)
win32print.EndPagePrinter (p)
win32print.ClosePrinter(p)
We have tried ending the print with these commands, without any luck.

win32print.EndDoc(p)
win32print.EndPagePrinter(p) 
win32print.EndDocPrinter(p11)
Other commands

Then we found other web pages saying that we should send a specific command to the printer, to make the cut. In that approach we had to initialise the printer differently. We made a few tries to do that.

p = printer.Usb( 0x04b8 , 0x0202 )
That gave the error NoBackendError, which was solved by installing libusb-win32-devel-filter-1.2.6.0.exe, and then we got USBNotFoundError.

Then we tried

p = Usb( 0x04b8 , 0x0202 , 0 , profile="TM-T20II")
Which said: Unexpected keyword argument 'profile'.

We did a little to solve that, but didn’t succeed.

Then we wrote:

from escpos.connections import getUSBPrinter
p = getUSBPrinter()(idVendor= 0x1504,
                    idProduct= 0x0006,
                    inputEndPoint= 0x82,
                    outputEndPoint= 0x01)
With the error: Cable isn’t plugged in. Tried to install a libusb-win32filter, again without luck.

Went back to the win32 Api, and found these links: C# CUSTOM VKP80iii Paper Ejector/Paper Cut What is the paper cut command? https://mike42.me/blog/what-is-escpos-an...o-i-use-it

Okay, the mindset now is to make a command to the pos print. We knew that commands to the pos print, wasn’t our best thing, but the idea was that the text was sent to the printer with the commands:

try
○ cutTxt = "0001 1100 0101 1000 0000 0101 0000 0001 0100 0101
0000 0101".encode()
try
○ cutTxt = bytearray("28 80 5 1 69 5", "utf-8")
try
○ GS = str( 29 )
○ ESC = str( 27 )
○ cutTxt = ""
○ cutTxt = ESC + "@"
○ cutTxt += GS + "V"
Followed by
○ win32print.WritePrinter (p, cutTxt)
It just printed exactly what we wrote to the printer

Settings

Last but not least, we found the pos printer on the computer, went into the settings, to see if there was some settings we could change to make it cut. And you guessed it, we had no success. But we tried to print some test prints, and when doing that, it made the partial cut without any problem.
Reply
#2
what exactly "to cut" should mean in this context? sorry, I see - to cut the paper
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Rock Paper Scissors Project in Python ankitdixit 8 4,730 Feb-23-2024, 03:14 PM
Last Post: DPaul
  Rock paper scissors in python with "algorithm" Agat0 23 5,831 Mar-01-2022, 03:20 PM
Last Post: Agat0
  How to make print without newline but wait in between each print? Adrian_L 6 3,028 Apr-01-2021, 09:59 PM
Last Post: Adrian_L
  how do I make a number only print once but the number keeps on decreasing? syafiq14 5 2,909 Jan-03-2020, 10:34 AM
Last Post: perfringo
  Make color for string when print to console hadoan 6 3,344 Oct-31-2019, 01:40 PM
Last Post: hadoan
  how to make a mathematical operation without the command "print" ewar2606 4 2,896 Mar-15-2018, 07:19 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020