
how to convert XPS to JPG in C#
The XPS document format lets you share, create, print, and save digital docs, but it may require supporting software. If you are a .NET developer and need to export an XPS file to JPG/JPEG programmatically, this article shows how to convert XPS to JPG in C#.
The following points are covered:
C# .NET API to convert XPS to JPG
We use Conholdate.Total for .NET to convert XPS to JPG. This library lets you create, edit, and save XPS documents. Download the DLL or install the XPS conversion API via NuGet.
Install-Package Conholdate.Total
How to convert XPS to JPG/JPEG programmatically in C#
The XPS conversion API enables conversion of XPS files to JPG.
Steps to convert an XPS file to a JPG image:
- Initialize a Stream object for the XPS document.
- Create an XpsDocument instance using the XPS stream and an XpsLoadOptions object.
- Set up a JpegSaveOptions object with required parameters.
- Instantiate an ImageDevice object.
- Call
XpsDocument.Save(Device device, SaveOptions options)to save the JPG in the ImageDevice. - Use the ImageDevice to write the JPG to disk (see code sample).
The code sample below demonstrates XPS to JPG conversion in C#:
Get a free license
Obtain a free temporary license to test the API without evaluation limits.
Conclusion
You now know how to convert XPS to JPG in C# using an XPS conversion API. Visit the documentation to explore additional features of the library.
Ask a question
Post your questions or queries on our forum.