Convert XPS using API for Java

This article explains how to convert XPS files using C# on the example of XPS to JPEG Conversion.

Aspose.Page lets you convert XPS files using Java in high-quality BMP, JPG, TIFF, PNG, and PDF documents.

You can try the quality of Aspose.Page XPS to JPG conversion and view the results via free online XPS to JPG Converter or XPS Viewer

Aspose.Page Java XPS to JPG converter allows to convert XPS document to JPG image on any OS for which the Java Virtual Machine exists.

Take the next steps in order to run XPS to JPG conversion:

  1. Initialize an input stream for the input XPS document.

  2. Create an instance of the XpsDocument from the created earlier input stream.

  3. Specify SmoothingModeResolution, and other options of the JpegSaveOptions(or PdfSaveOptions if you convert to PDF format other save option from the listed).

  4. Create an instance of the ImageDevice(or PdfDevice if you convert to PDF format).

  5. Save the XPS document as an image with JPEG save options to an array of arrays of bytes. One array of bytes for one page of input document.

  6. Save resulting 2-dimensional arrays of bytes to JPG files creating for every byte array a new file output stream.

  7. Create an instance of XpsDocument from the XPS file.

  8. Specify SmoothingModeResolution and other options of JpegSaveOptions(or PdfSaveOptions if you convert to PDF or other save option from the listed).

  9. Save the XPS document as image with the save options to an array of arrays of bytes. One array of bytes for one page of an input document.

  10. Save resulting 2-dimensional arrays of bytes to JPEG files creating for every byte array a new file output stream.

                
            

See XPS to JPG conversion in .NET and C++.

Let’s consider JpegSaveOptions. Using this class we can assign different conversion parameters while converting XPS to JPG.

For converting XPS to PDF there are next parameters here:

Evaluate XPS online in our XPS cross-platform Converter. You can convert several XPS files to JPG at once and download results in a few seconds.

You can download examples and data files from GitHub.

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.