Java/ Convert PDF to PostScript
Postscript is a dynamically typed, concatenative programming language that describes the appearance of a printed page. Owing to its faster printing and improved quality, sometime you may need to convert a PDF document to Postscript. This article will introduce how to accomplish this task using Free Spire.PDF for Java.
Import JAR Dependency
● You can download the free API and unzip it. Then add the Spire.Pdf.jar file to your project as dependency.
● Or you can directly add the jar dependency to maven project by adding the following configurations to the pom.xml.
<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.pdf.free</artifactId>
<version>4.3.0</version>
</dependency>
</dependencies>Get Andrew Wilson’s stories in your inbox
Join Medium for free to get updates from this writer.
Sample Code
The detailed steps and sample code to convert PDF to PostScript are as follows:
- Create a PdfDocument object.
- Load a sample PDF file using PdfDocument.loadFromFile() method.
- Save the document as PostScript using PdfDocument.saveToFile() method.
import com.spire.pdf.*;
public class PDFToPS {
public static void main(String[] args) {
//Load a pdf document
PdfDocument doc = new PdfDocument();
doc.loadFromFile("C:\\Users\\Administrator\\Desktop\\Travel.pdf");
//Convert to PostScript file
doc.saveToFile("output.ps", FileFormat.POSTSCRIPT);
}
}







