Convert PostScript to PNG in Java

Let’s continue exploring the functionalities offered by Aspose.Page for Java. Since we already know that we need a third-party application to view/process PostScript files. However, converting them to image file formats will surely remove this hassle. So, this blog post will walk through the implementation of converting PS to PNG using Aspose.Page for Java. It involves a few lines of Java source code to develop a PS to PNG converter programmatically. Now, let us jump to the installation and then write a code sample to convert PostScript to PNG in Java.

This article involves the following points:

Java PostScript SDK Installation

So, you can download this JAR file or use the Maven configurations mentioned below. Further, there are complete installation and usage instructions given here.

         <name>Aspose Java API</name>

Convert PostScript to PNG in Java

Well, enough with the theory let’s see some code. But before moving ahead, please make sure you have a source PostScript file to test the functionality.

The following steps show how to convert PS to PNG programmatically:

  • First, set the ImageFormat to PNG and load the source PostScript(PS) file.
  • Create an instance of the PsDocument class with the input stream of PostScript.
  • You can set the value of suppressErrors if you want to convert the Postscript file despite minor errors.
  • Initialize a new instance of the ImageSaveOptions class with the suppressErrors parameter.
  • Instantiate an object of the ImageDevice class.
  • Invoke the save method to save the PNG file on the disk.
  • Call the getImagesBytes method to get the resulting images in bytes.
  • Now, create an output stream by initializing an instance of the FileOutputStream class with the output image path.


Convert PostScript to PNG in Java

PS to PNG Converter - Online App

So far, you have seen how this Java PostScript SDK offers programmatic conversion. Now, the other cool thing about this library is that it also provides an online tool to convert PostScript files to image file formats. Above all, this PS to PNG converter is free and you can use it by opening it into any web browser.

PS to PNG Converter - Online App

Get a Free License

You can get a free temporary license to try this Java PostScript SDK without evaluation limitations.

Summing up

We are winding up this guide here. In order to get started, please visit the documentation, API references and GitHub repo. We have covered how to convert PostScript to PNG in Java using Aspose.Page for Java. Moreover, this blog post is an effort to introduce this Java PostScript SDK as a solution and we hope it will help you in developing a PS to PNG converter for your business application. Lastly, please stay connected with for the regular updates.

Feel Free to Reach Out

You can let us know about your questions or queries on our forum.

See Also