EPS (Encapsulated PostScript) is a graphics file format, used to describe images or drawings. EPS file may contain any combination of text, graphics and images. PostScript PS/EPS files are commonly used for printing purposes as they are based on Page Description Languages. We can easily convert EPS or PS files to PNG images programmatically. In this article, we will learn how to convert EPS to PNG in Java.
The following topics shall be covered in this article:
Java EPS to PNG Converter API – Free Download
The PsDocument class of the API encapsulates PS/EPS documents. The ImageSaveOptions class of the API contains the options necessary for managing the image-saving process. The ImageDevice class encapsulates the rendering of the document to image. The getImagesBytes() method gets the resulting images in bytes. The save(Device, SaveOptions) method saves the PS/EPS document to a device. The ImageFormat enumeration contains possible names of image formats that are supported by PS/EPS to Image conversion.
Please either download the JAR of the API or add the following pom.xml configuration in a Maven-based Java application.
<repository> <id>AsposeJavaAPI</id> <name>Aspose Java API</name> <url>https://repository.aspose.com/repo/</url> </repository>
<dependency> <groupId>com.aspose</groupId> <artifactId>aspose-page</artifactId> <version>22.7</version> </dependency>
Convert EPS to PNG Image using Java
We can convert PostScript EPS or PS files to PNG images by following the steps given below:
- Load EPS file in the FileInputStream.
- Create an instance of the PsDocument class with the stream object.
- Initialize the ImageSaveOptions class object with the necessary parameters.
- Set the output ImageFormat as PNG.
- Create an instance of the ImageDevice class.
- Call the save() method to save the image in ImageDevice.
- After that, call the Device.getImagesBytes() method to get image bytes.
- Finally, save it as an image.
The following code example shows how to convert EPS or PS file to a PNG image using Java.
Free API License
You can get a free temporary license to try the library without evaluation limitations.
In this article, we have learned how to convert a PostScript EPS/PS file to PNG images programmatically using Java. Besides, you can learn more about Aspose.Page for Java API using the documentation. In case of any ambiguity, please feel free to contact us on our forum.