Download Now
Home Using
 
How To Convert Documents To XPS

To convert a document to XPS, you must instantiate an XPSRenderer, passing it the name of the printer you created. If no printer name is passed in, it will look for a printer of the default name, "Convert2XPS".

Simply call 'Convert2XPS', passing in the path to the file you wish to convert. The method will return a path to the XPS file, which is created in your Temp folder. You can then copy and name this file as required.

XpsRenderer renderer = new XpsRenderer();
string xpsFile = renderer.Convert2XPS(originalFile);

Can I Get Progress Feedback?

Of course. Both the Printer class and the XpsRenderer class support progress feedback via events.

Printer.UpdateProgress   
Printer.InitialiseProgress
Printer.Finished         

XpsRenderer.ProgressStatus

Can I Perform The Conversion On a Different Thread?

Yes. The only thing you to be aware of is that the built in HTML renderer only works if your thread's apartment state is set to single threaded:

_myThread.SetApartmentState(ApartmentState.STA);

Learn how to deploy...