R – Suppressing the Save As dialog on Microsoft XPS Document Writer when converting GDI To XPS

gdi+printingwindowsxps

In his blog entry Printing documents to Microsoft XPS Document Writer without user interaction Feng Yuan says

If you're printing from your own applications, it's easy to specify MXDW as the printer driver and provide a file name for the XPS document to be saved to

Can anyone explain how to do that and provide a code sample?

The main problem I am having is suppressing the Save As dialog that the Microsoft XPS Document Writer pops up. I am loathed to resort to UI hacking as Yuan does in his post.

Currently my application makes GDI drawing calls on the Device Context of what ever printer the user wants to use. I can make those calls on the XPS Document Writer fine, but when it come times to complete the printing the XPS Writer pops up the save as dialog box.

Best Answer

Indeed the same author provides the answer Printing to Microsoft XPS Document Writer without showing File Save Dialog Box. The solution is to print to a file using the Microsoft XPS Document Writer printer.

Related Topic