title: Python27 - on windows 10 how can i tell printing paper size is 50.8mm x 25.4mm?
body: <p>I have this code on windows which is working with A4 printers. But i have a very small printer, when i print something it does not print anything but only push the ticket out.</p>
  
  <p><a href="https://i.stack.imgur.com/QJvcB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QJvcB.jpg" alt="enter image description here"></a></p>
  
  <p>TRY0:</p>
  
  <pre><code>import win32ui
  X=0; Y=0
  input_string = "Print 1234 test"
  multi_line_string = input_string.split()
  hDC = win32ui.CreateDC ()
  hDC.CreatePrinterDC ('Dymo label printer')
  hDC.StartDoc ('FILE NAME FILE NAME')
  hDC.StartPage ()
  for line in multi_line_string:
       hDC.TextOut(X,Y,line)
       #Y += 100
  hDC.EndPage ()
  hDC.EndDoc ()
  </code></pre>
  
  <p>TRY1: faling to print same like before: <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd319099(v=vs.85).aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/windows/desktop/dd319099(v=vs.85).aspx</a></p>
  
  <pre><code>import win32ui
  import win32con
  import win32print
  import win32gui
  
  X=0
  Y=0
  input_string = "A390"
  
  printer = win32print.GetDefaultPrinter()
  hprinter = win32print.OpenPrinter(printer)
  devmode = win32print.GetPrinter(hprinter, 2)["pDevMode"]
  
  # change paper size and orientation
  # constants are available here:
  # http://msdn.microsoft.com/library/default.asp?
  #      url=/library/en-us/intl/nls_Paper_Sizes.asp
  # number 10 envelope is 20
  devmode.PaperSize = 20
  # 1 = portrait, 2 = landscape
  devmode.Orientation = 1
  
  hdc = win32gui.CreateDC("WINSPOOL", printer, devmode)
  dc = win32ui.CreateDCFromHandle(hdc)
  dc.StartDoc ('test')
  dc.StartPage ()
  dc.TextOut(X,Y,input_string)
  #for line in multi_line_string:
       #hDC.TextOut(X,Y,line)
  dc.EndPage ()
  dc.EndDoc ()
  </code></pre>
  
  <p>TRY2: FAIL</p>
  
  <pre><code>import win32ui
  import win32con
  import win32print
  import win32gui
  
  printer = win32print.GetDefaultPrinter()
  hprinter = win32print.OpenPrinter(printer)
  devmode = win32print.GetPrinter(hprinter, 2)["pDevMode"]
  devmode.PaperSize = 20
  devmode.Orientation = 2
  
  hDC = win32gui.CreateDC ("WINSPOOL", printer, devmode)
  dc = win32ui.CreateDCFromHandle(hDC)
  dc.StartDoc ('test')
  dc.StartPage ()
  
  #hDC.SetMapMode(MM_TEXT) # ERROR no MM_TEXT found...
  font = win32ui.CreateFont({
      "name": "Lucida Console",
      "height": 50,
      "weight": 50,
  })
  win32print.DocumentProperties(0, hprinter, '300LN1', None, None, 5)
  dc.SelectObject(font)
  dc.TextOut(10,10,"TEST...")
  dc.TextOut(10,-10,"TEST..")
  
  dc.EndPage ()
  dc.EndDoc ()
  </code></pre>
  
  <p>TRY3: FAIL</p>
  
  <pre><code>import win32ui
  import win32print
  import win32con
  
  INCH = 1440
  
  hDC = win32ui.CreateDC ()
  hDC.CreatePrinterDC (win32print.GetDefaultPrinter ())
  hDC.StartDoc ("Test doc")
  hDC.StartPage ()
  hDC.SetMapMode (win32con.MM_TWIPS)
  hDC.DrawText ("TEST", (0, INCH * -1, INCH * 8, INCH * -2), win32con.DT_CENTER)
  hDC.EndPage ()
  hDC.EndDoc ()
  </code></pre>