XPS files are used to save documents in the page description language. You may need to convert an XPS file to an image for previewing the contents or creating thumbnails. In accordance with such scenarios, this article covers how to convert XPS to JPG or PNG images using Java.
- XPS to JPG or PNG Image Converter – Java API Installation
- Convert XPS to JPG Image in Java
- Convert XPS to PNG Image in Java
XPS to JPG or PNG Image Converter – Java API Installation
XPS files can be converted to different image formats. Simply configure Aspose.Page for Java API by downloading the JAR files or with the following Maven configurations to download the APIs from Aspose Repository:
<repositories> <repository> <id>snapshots</id> <name>repo</name> <url>http://repository.aspose.com/repo/</url> </repository> </repositories>
<dependencies> <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-page</artifactId> <version>21.12</version> </dependency> </dependencies>
Convert XPS to JPG Image in Java
You can convert an XPS to JPG Image in Java with the following steps:
- Load input XPS file with XpsDocument class.
- Initialize JpegSaveOptions object with necessary parameters.
- Create rendering device for image.
- Write output JPG file.
The following code snippet shows how to convert XPS file to JPG image programmatically in Java:
Convert XPS to PNG Image in Java
You can convert an XPS to PNG Image in Java with the following steps:
- Load the source XPS document using XpsDocument class.
- Instantiate PngSaveOptions instance to set different properties.
- Initialize a rendering device using ImageDevice class.
- Write the output PNG image.
The code snippet below demonstrates how to convert an XPS file to PNG image programmatically in Java:
Get Free Evaluation License
You can evaluate the API in its full capacity by requesting a free temporary license.
In this article, you have learned how to convert an XPS file to JPG or PNG image programmatically using Java. Furthermore, you can explore many other features offered by the API by visiting the documentation. Please feel free to get in touch with us at the forum.