We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Platform : WPF
|
Category : Printing

How can I programmatically print XPS Files ?

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.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.