title: Redirecting the output of a virtual printer to a Python script
body: <p>My intention is to achieve the following scenario:  </p>
  
  <ul>
  <li><p>A Windows or Linux user gives the command to print a document (using Ctrl+P) and views a dummy printer (virtual printer) in the list of available printers  </p></li>
  <li><p>The user selects the printer and gives the print command  </p></li>
  <li><p>Instead of actually printing, the dummy printer automatically sends the file, along with the selected paper size, format and so on, to a python script as input [optionally after converting it to PDF].</p></li>
  <li><p>The Python script uploads the file to the cloud or some remote storage from where it can be retrieved and printed later on a physical printer when required.  </p></li>
  </ul>
  
  <p>I have already referred the answer to a similar existing question on StackOverflow and looked up CUPS and CUPS-PDF. CUPS_PDF is a virtual printer so that satisfies one criteria for me, but it doesn't let me handle the files sent for printing. I could monitor the directory in which the converted PDFs are placed and call the python script every time the directory changes, but that is far from an ideal solution.    </p>
  
  <p>I tried creating something similar in Windows by using win32 API in the form of a FILE printer, but again it doesn't let me handle the file to be printed.</p>
  
  <p>I have also stumbled across Tea4CUPS which is kind of a programmable backend for the CUPS printer, but I am not really sure how to leverage that. Another alternative I encountered was to write a Virtual printer driver using Windows Driver Kit (WDK), but that seems overly complicated especially given the fact that I need the Virtual Printer to just redirect the file to be printed to my python script.  </p>
  
  <p>How can I achieve my desired scenario? Though I have Python experience, I have never worked on Virtual printers before this.</p>