title: Dot-matrix printer doesn't moves to next tear off position after printing using python
body: <p>I am using Epson FX2175 dot matrix printer and win32print python library to give commands to printer. After printing is completed paper doesn't moves to next tear off position.</p>
  <p>I tried sending FF(form feed) command at the end but it advances paper too much instead of moving as my paper size i.e. 15.4 cm. Paper size has been configured in printer preferences &gt; paper size &gt; user defined.</p>
  <p>Below is my python code</p>
  <pre><code>import os, sys
  import win32print
  
  def formatData(args):
    cnt = 1;
    decimal_form_feed = 12
    decimal_line_feed = 10
    decimal_carriage_return = 13
  
    byteArr = bytearray()
  
    # Reverse feed
    # byteArr.extend(bytes(&quot;\u001bj2&quot;, &quot;utf-8&quot;))
  
    # byteArr.extend(bytes(&quot;\u001b$0&quot;, &quot;utf-8&quot;))
  
    # ESC J Advance print position vertically
    # param n where 0 &lt;= n &lt;=255
    # Advances vertical position n/216 or n/180 inches
  
    # Set page size in terms of line numbers
    # byteArr.extend(bytes(&quot;\u001bC10&quot;, &quot;utf-8&quot;))
    print(len(args))
    while(cnt &lt; len(args)):
      if args[cnt]==&quot;R&quot;:
        temp = bytes (args[cnt+1], &quot;utf-8&quot;)
        byteArr.extend(temp)
        #print(byteArr)
      elif args[cnt]==&quot;RB&quot;:
        temp = bytes (&quot;\u001bE&quot;+args[cnt+1]+&quot;\u001bF&quot;, &quot;utf-8&quot;)
        byteArr.extend(temp);
        #print(byteArr)
      elif args[cnt]==&quot;D&quot;:
        temp = bytes (&quot;\u001b\u000e&quot;+args[cnt+1]+&quot;\u001b\u0012&quot;, &quot;utf-8&quot;)
        byteArr.extend(temp);
      elif args[cnt]==&quot;DB&quot;:
        temp = bytes (&quot;\u001b\u000e&quot;+args[cnt+1]+&quot;\u001b\u0012&quot;, &quot;utf-8&quot;)
        byteArr.extend(temp);
      elif args[cnt]==&quot;newline&quot;:
        temp = bytes (&quot;\n&quot;, &quot;utf-8&quot;)
        byteArr.extend(temp);
        cnt = cnt+1
        continue
      elif args[cnt]==&quot;lf&quot;:
        mCnt = 0
        while mCnt &lt; int(args[cnt+1]):
          mCnt = mCnt+1
          byteArr.extend(bytes(&quot;\n&quot;, &quot;utf-8&quot;))
          #byteArr.extend(bytes(&quot;\u001bJ1&quot;, &quot;utf-8&quot;))
      elif args[cnt]==&quot;rf&quot;:
        mCnt = 0
        while mCnt &lt; int(args[cnt+1]):
          byteArr.extend(bytes(&quot;\u001bj2&quot;, &quot;utf-8&quot;))
          mCnt = mCnt+1
        
      cnt = cnt+2;
    byteArr.extend(decimal_carriage_return.to_bytes(2, 'big'))
    byteArr.extend(decimal_form_feed .to_bytes(2, 'big'))
    #byteArr.extend(decimal_carriage_return.to_bytes(2, 'big'))
    #byteArr.extend(decimal_line_feed.to_bytes(2, 'big'))
    print(byteArr)
    mBytes = bytes(byteArr)
    return mBytes
      
  
  printer_name = win32print.GetDefaultPrinter ()
  
  raw_data = formatData(sys.argv);
  hPrinter = win32print.OpenPrinter (printer_name)
  try:
    hJob = win32print.StartDocPrinter (hPrinter, 1, (raw_data.decode(&quot;utf-8&quot;), None, &quot;RAW&quot;))
    try:
      win32print.StartPagePrinter (hPrinter)
      win32print.WritePrinter (hPrinter, raw_data)
      win32print.EndPagePrinter (hPrinter)
    finally:
      win32print.EndDocPrinter (hPrinter)
  finally:
    win32print.ClosePrinter (hPrinter)
  </code></pre>
  <p>I am using this manual for reference <a href="https://files.support.epson.com/pdf/general/escp2ref.pdf" rel="nofollow noreferrer">Epson EscP manual reference</a></p>
  <p>Any help is very much appreciated since I am struglling with this for almost 5 days.</p>