title: Silent printing of a PDF in Python
body: <p>I'm trying to print a PDF with Python, without opening the PDF viewer application (Adobe, Foxit etc.). I need also to know when printing has finished (to delete the file).</p>
  
  <p><a href="http://permalink.gmane.org/gmane.comp.python.windows/6558" rel="noreferrer">Here</a> I found this <strong>implementation</strong>:</p>
  
  <pre><code>import win32ui, dde, os.path, time
  from win32api import FindExecutable
  from os import spawnl, P_NOWAIT
  ...
  pd = "C:\\temp\\test.pdf"
  pdbits = os.path.split(pd)
  readerexe = FindExecutable(pdbits[1],pdbits[0])
  
  spawnl(P_NOWAIT,readerexe[1],"DUMMY") #I added "DUMMY" to avoid a weird error
  
  time.sleep(2)
  
  s = dde.CreateServer()
  s.Create('')
  c = dde.CreateConversation(s)
  c.ConnectTo('acroview', 'control')
  
  c.Exec('[FilePrintSilent("%s")]' % (pd,))
  
  s.Destroy()
  </code></pre>
  
  <p>But it throws this exception at the <code>ConnectTo</code> line:</p>
  
  <pre><code>dde.error: ConnectTo failed
  </code></pre>
  
  <p>Someone knows how to solve it? Or has a <strong>different solution</strong> for silent printing? Or at list can give a link to a <strong>reference for <code>ConnectTo</code></strong>? Could find nothing on the web about it.</p>
  
  <p>Working with: Python 2.7, Windows 7, Acrobat Reader 10.0</p>