
how to convert XPS to JPG in C#
The XPS document format allows you to easily share, create, print, and save digital docs, but you may have to install the supporting software. If you are a .NET programmer and may want to export an XPS file to JPG/JPEG format programmatically, this article will explain how to convert XPS to JPG in C#.
The following points will be covered in this article:
C# .NET API to convert XPS to JPG
In this article, we will use Conholdate.Total for .NET to convert XPS to JPG. This library enables you to create, edit and save existing as well as new XPS documents. Therefore, you can download the DLL or install this XPS conversion API using NuGet.
Install-Package Conholdate.Total
How to convert XPS to JPG/JPEG programmatically in C#
The XPS conversion API allows you to convert your XPS files to JPG.
The following are the steps to convert an XPS file to a JPG image:
- Initialize the object of Stream class for XPS documents.
- Create an instance of XpsDocument class by using the XPS stream (created in the previous step) and the object of XpsLoadOptions class as parameters.
- Initialize the object of JpegSaveOptions class with necessary parameters.
- Create an instance of the ImageDevice class.
- Save the JPG in ImageDevice object by invoking the XpsDocument.Save(Device device, SaveOptions options).
- Use the ImageDevice to save the JPG on the disc (as shown in the code sample below).
The following code sample shows how to convert XPS to JPG conversion using C#:
Get a free license
You can acquire a free temporary license to test the API without evaluation limitations.
Conclusion
To conclude this article, we hope you have learned how to convert XPS to JPG in C# using an XPS conversion API. You may visit the documentation to explore other features of the XPS conversion library.
Ask a question
You can let us know your questions or queries on our forum.