Printing XPS files to a physical printer
I had the need to programatically print an XPS file, but a couple of hours of Google searches only returned examples of how to print TO an XPS file. It was extremely difficult to find how to send a XPS file to an actual physical printer.
Eventually something turned up and the solution seemed to be the XpsDocument class.
Look at this simplified example to see how easy it turned out to be:
PrintDialog dlg = new PrintDialog(); XpsDocument xpsDoc = new XpsDocument(PATH_TO_YOUR_XPS_FILE_HERE, System.IO.FileAccess.Read); dlg.PrintDocument(xpsDoc.GetFixedDocumentSequence().DocumentPaginator, "Document title");
As you can see, reading a XPS file and then sending the contents to a printer is not very hard at all.