title: python win32print not printing
body: <p>I need to print some information directly (without user confirmation) and I'm using Python and the <code>win32print</code> module. </p>
  
  <p>I've already read the whole <a href="http://timgolden.me.uk/python/win32_how_do_i/print.html" rel="nofollow">Tim Golden win32print page</a> (even read the <a href="http://timgolden.me.uk/pywin32-docs/win32print.html" rel="nofollow">win32print doc</a>, which is small) and I'm using the same example he wrote there himself, but I just print nothing. </p>
  
  <p>If I go to the interactive shell and make one step at a time, I get the document on the printer queue (after the <code>StartDocPrinter</code>), then I get the document size (after the <code>StartPagePrinter, WritePrinter, EndPagePrinter</code> block) and then the document disappear from the queue (after the <code>EndDocPrinter</code>) without printing.</p>
  
  <p>I'm aware of the <code>ShellExecute</code> method Tim Golden showed. It works here, but it needs to create a temp file and it prints this filename, two things I don't want.</p>
  
  <p>Any ideas? Thanks in advance. </p>
  
  <p>This is the code I'm testing (copy and paste of Tim Golden's):</p>
  
  <pre><code>import os, sys  
  import win32print
  import time
  printer_name = win32print.GetDefaultPrinter()
  if sys.version_info &gt;= (3,):
      raw_data = bytes ("This is a test", "utf-8")
  else:
      raw_data = "This is a test"
  
  hPrinter = win32print.OpenPrinter (printer_name)
  try:
      hJob = win32print.StartDocPrinter (hPrinter, 1, ("test of raw data", None, "RAW"))
      try:
          win32print.StartPagePrinter (hPrinter)
          win32print.WritePrinter (hPrinter, raw_data)
          win32print.EndPagePrinter (hPrinter)
      finally:
          win32print.EndDocPrinter (hPrinter)
  finally:
      win32print.ClosePrinter (hPrinter)
  </code></pre>
  
  <p>[EDIT]</p>
  
  <p>I installed a pdf printer in my computer to test with another printer (CutePDF Writer) and I could generate the <code>test of raw data.pdf</code> file, but when I look inside there is nothing. Meaning: all commands except <code>WritePrinter</code> appears to be doing what they were supposed to do. But again, as I said in the comments, <code>WritePrinter</code> return the correct amount of bytes that were supposed to be written to the printer. I have no other idea how to solve this, but just comproved there is nothing wrong with my printer.</p>