Python print pdf file with win32print
<p>I'm trying to print a pdf file from Python with module <code>win32print</code> but the only way I can print success is a text.</p>

<pre><code>hPrinter = win32print.OpenPrinter("\\\\Server\Printer")
filename = "test.pdf"
try:
    hJob = win32print.StartDocPrinter(hPrinter, 1, ('PrintJobName', None, 'RAW'))
    try:
        win32api.ShellExecute(0, "print", filename, None, ".", 0)
        win32print.StartPagePrinter(hPrinter)
        win32print.WritePrinter(hPrinter, "test")  # Instead of raw text is there a way to print PDF File ?
        win32print.EndPagePrinter(hPrinter)
    finally:
        win32print.EndDocPrinter(hPrinter)
finally:
    win32print.ClosePrinter(hPrinter)

</code></pre>

<p>So instead of printing a text I need to print the "test.pdf" file.</p>

<p>I also tried with <strong><code>win32api.ShellExecute(0, "print", filename, None,  ".",  0)</code></strong> but it's not working, after some test like (getprinter, getdefault, setprinter, setdefaultprinter) it seems not to be attaching the printer. So at this way I can't get working.</p>

<p>This is the code I used !</p>

<pre><code>win32print.SetDefaultPrinter(hPrinter)
win32api.ShellExecute(0, "print", filename, None,  ".",  0)
</code></pre>