title: Creating XPS file with the Microsoft XPS Document Writer programatically
body: <p>I'm investigating a batch printing solution.  </p>
  
  <p>The files to be printed will be in various (typical) formats, e.g., PDF, Word, Excel, etc.  From what I've gathered (and tested) printing XPS files is the way to go on a Windows platform.  </p>
  
  <p>However, it's completely unclear to me how one actually creates an XPS file - without intimate knowledge of the input file format in question (<em>programmatically</em> that is).    </p>
  
  <p>My hope was that I could print to the local <em>Microsoft XPS Document Writer</em> "printer" and then physically print its output (i.e., the XPS file).</p>
  
  <p>I'm unable to do this successfully programmatically.  I've tried with managed code <code>System.Printing</code>, unmanaged code <code>Winspool API</code>.</p>
  
  <p>I can successfully open the printer and write raw data to it, but I never get an XPS file output.  How does one create XPS files?  I've looked at the <code>XPSDocumentWriter</code> API but this seems very complex and, presumably, has already been implemented by the <em>Microsoft XPS Document Writer</em> and/or existing applications.</p>