title: Python printing a pdf file on my Brother Laser printer (Duplex print on/off)
body: <p>I want to write a python script that prints each file in a Folder on my laser Printer.
  There should be the possibility to Switch the Duplex  print mode on and off.
  The decission is made by the file Name. If there is a D in front of the file Name it is a Duplex and if there is a S it is a simplex.
  This I havent implemented so far.</p>
  
  <p>My Problem is how do I tell the Printer to use Duplex mode?</p>
  
  <p>Here is my code</p>
  
  <pre><code>from os import path  
  from os import listdir  
  from os.path import isfile, join  
  import win32api  
  import win32print  
  
  mypath = r"D:\\test"  
  
  #list all the files in a folder  
  files = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ]  
  print files
  
  
  for file in files:  
      file = mypath + "\\" + file  
  ##    if "11x17" in file and "County" in file:
      win32api.ShellExecute (
          0,
          "print",
          file,  
            #  
            # If this is None, the default printer will  
            # be used anyway.  
            #
          '/d:"%s"' % win32print.GetDefaultPrinter (),
          ".",
          0
          )  
  
  del files  
  del mypath  
  </code></pre>
  
  <p>an alternative would be this (i have to add the Loop for all files)</p>
  
  <pre><code>from subprocess import call
  
  acrobat = "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" ##     Acrobat reader would also work, apparently
  file = "D:\\Test\\test.pdf"
  printer = "gDoc Creator"
  
  call([acrobat, "/T", file, printer])
  </code></pre>
  
  <p>now I know this exists</p>
  
  <pre><code>#Lists properties and capabilities for all the printers installed on a computer.  
  import win32com.client
  strComputer = "."  
  objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")  
  objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2")  
  colItems = objSWbemServices.ExecQuery("Select * from  Win32_PrinterConfiguration")  
  for objItem in colItems:  
      print "Duplex: ", objItem.Duplex  
  </code></pre>
  
  <p>This value can get TRUE and FALSE, but is there a way to send it when I want to print with my script?</p>
  
  <p>Tahnks in advance for your help.</p>