The PostScript (PS) file format is mainly used for printing purposes. A PS file is saved in page description language and can contain text, vector graphics, and raster images. On the other hand, the Encapsulated PostScript (EPS) format is used for images or drawings. In certain cases, you may need to convert a PS or EPS file to PDF format. Therefore, this article covers how to perform this conversion programmatically. Particularly, you will learn how to convert PS and EPS files to PDF using Java.
Java PS or EPS to PDF Converter API
Aspose.Page for Java API is designed to work with PS and EPS files from within the Java applications. Along with other manipulation features, the API provides a high fidelity conversion of PS/EPS to PDF. You can either download the API’s JAR or install it within your Maven-based 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>20.12</version> </dependency>
Steps to Convert PS or EPS to PDF in Java
The following are the steps to convert a PS or EPS file to PDF using Aspose.Page.
- Load the file using the PsDocument class.
- Create an instance of PdfSaveOptions class and set PDF options if required.
- Define an instance of FileOutputStream for output PDF file.
- Create an instance of PdfDevice class and initialize it with output PDF’s FileOutputStream object.
- Save document as PDF using PsDocument.save(PdfDevice, PdfSaveOptions) method.
The following code sample shows how to convert an EPS or PS to PDF using Java.
In this article, you have learned how to convert EPS or PS files to PDF using Java. You can explore more about the EPS or PS file manipulation API using the documentation.