You can use one overload of the AddJob() method to print XML Paper Specification (XPS) files without opening a PrintDialog or in principle, any user interface (UI) at all. You can also print XML Paper Specification (XPS) files using the many Write() and WriteAsync() methods of the XPSDocumentWriter. Another way of printing XML Paper Specification (XPS) is to use the PrintDocument() or PrintVisual() methods of the PrintDialog control.
The main steps to use the three-parameter AddJob(String, String, Boolean) method are as follows.
The example below gives details.
1. Determine if the printer is an XPSDrv printer.
2. The printer is not an XPSDrv printer, set the thread’s apartment to a single thread.
3. Instantiate a print server and print queue object.
4. Call the method specifying a job name, the file to be printed and a Boolean flag indicating whether or not the printer is an XPSDrv printer.