title: POS receipt print cannot make paper cut using python
body: <p><strong>Problem</strong></p>
  
  <p>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.</p>
  
  <p><strong>Win32 API</strong> </p>
  
  <p>We have tried with Win32 API which work as well but we cannot find a command telling the
  receipt printer to "cut".</p>
  
  <p>We have tried the following with win32: </p>
  
  <pre class="lang-py prettyprint-override"><code>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)
  </code></pre>
  
  <p>We have tried ending the print with these commands, without any luck.</p>
  
  <pre class="lang-py prettyprint-override"><code>win32print.EndDoc(p)
  win32print.EndPagePrinter(p) 
  win32print.EndDocPrinter(p11)
  </code></pre>
  
  <p><strong>Other commands</strong></p>
  
  <p>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>
  
  <pre class="lang-py prettyprint-override"><code>p = printer.Usb( 0x04b8 , 0x0202 )
  </code></pre>
  
  <p>That gave the error <code>NoBackendError</code>, which was solved by installing
  <code>libusb-win32-devel-filter-1.2.6.0.exe</code>, and then we got <code>USBNotFoundError</code>.</p>
  
  <p>Then we tried</p>
  
  <pre class="lang-py prettyprint-override"><code>p = Usb( 0x04b8 , 0x0202 , 0 , profile="TM-T20II")
  </code></pre>
  
  <p>Which said: <code>Unexpected keyword argument 'profile'</code>. </p>
  
  <p>We did a little to solve that, but didn’t succeed.</p>
  
  <p>Then we wrote:</p>
  
  <pre class="lang-py prettyprint-override"><code>from escpos.connections import getUSBPrinter
  p = getUSBPrinter()(idVendor= 0x1504,
                      idProduct= 0x0006,
                      inputEndPoint= 0x82,
                      outputEndPoint= 0x01)
  </code></pre>
  
  <p>With the error: <code>Cable isn’t plugged in</code>. Tried to install a <code>libusb-win32</code>filter, again without luck.</p>
  
  <p>Went back to the win32 Api, and found these links:
  <a href="https://stackoverflow.com/questions/55550276/c-sharp-custom-vkp80iii-paper-ejector-papercut">C# CUSTOM VKP80iii Paper Ejector/Paper Cut</a>
  <a href="https://stackoverflow.com/questions/34671045/what-is-the-paper-cut-command">What is the paper cut command?</a>
  <a href="https://mike42.me/blog/what-is-escpos-and-how-do-i-use-it" rel="nofollow noreferrer">https://mike42.me/blog/what-is-escpos-and-how-do-i-use-it</a></p>
  
  <p>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:</p>
  
  <ul>
  <li><ol>
  <li>try <br />
  ○ cutTxt = "0001 1100 0101 1000 0000 0101 0000 0001 0100 0101 <br />
          0000 0101".encode() <br /></li>
  </ol></li>
  <li><ol start="2">
  <li>try <br /> 
  ○ cutTxt = bytearray("28 80 5 1 69 5", "utf-8") <br /></li>
  </ol></li>
  <li><ol start="3">
  <li>try<br>
  ○ GS = str( 29 ) <br />
  ○ ESC = str( 27 ) <br />
  ○ cutTxt = "" <br />
  ○ cutTxt = ESC + "@" <br />
  ○ cutTxt += GS + "V" <br /></li>
  </ol></li>
  <li><p>Followed by <br />
  ○ win32print.WritePrinter (p, cutTxt) <br /> 
  It just printed exactly what we wrote to the printer <br /></p></li>
  </ul>
  
  <p><strong>Settings</strong> <br /></p>
  
  <p>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.</p>