Using C# 3.5, I’m trying to programmatically create XPS files by sending them to the “Microsoft XPS Document Writer” printer. I’m able to set the print queue, but I’m unable to add a job to the print queue using the PrintQueue.AddJob() because it’s expecting a XPS file. I’ve also tried setting the PrintSystemInfo JobStream to a byte array to no avail.
Basically I want to mimic what a user does manually when printing to the “Microsoft XPS Document Writer”: 1. Select “Microsoft XPS Document Writer” from the list of printers. 2. Specify the new XPS file name. 3. Print it (which saves it as a .xps file)
I would think with the System.Printing and System.Windows.Xps namespaces there would be an easy way to do this. I’ve spent lots of time researching this and have seen other people trying to accomplish the same task, but no was able to provide an elegant solution.
Any insight would be much appreciated.
Thanks.