Java/ Convert PDF to PostScript

Andrew Wilson
1 min readDec 6, 2021

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>

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);

}
}

--

--

Andrew Wilson

Explore C#, Java and Python solutions for processing Word/Excel/PowerPoint/PDF files.