Java: Convert Word to PostScript

PostScript is a page description language designed by Adobe in 1984 for the purpose of printing. A file described in PostScript language may contain text, raster/vector graphics and can be printed by any printer that supports PostScript without being opened in an application. In some cases, you might need to convert your Word document to PostScript. This article will show you how to achieve this task programmatically in Java using Spire.Doc for Java.

Install Spire.Doc for Java

First of all, you're required to add the Spire.Doc.jar file as a dependency in your Java program. The JAR file can be downloaded from this link. If you use Maven, you can easily import the JAR file in your application by adding the following code to your project's pom.xml file.

<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.doc</artifactId>
        <version>12.11.0</version>
    </dependency>
</dependencies>
    

Convert Word to PostScript

The following are the steps to convert a Word document to PostScript:

  • Create an instance of Document class.
  • Load a Word document using Document.loadFromFile() method.
  • Save the document to PostScript using Document.saveToFile() method.
  • Java
import com.spire.doc.Document;
import com.spire.doc.FileFormat;

public class ConvertWordToPostScript {
    public static void main(String[] args){
        //Create a Document instance
        Document document= new Document();
        //Load a Word document
        document.loadFromFile("Sample.docx");
        
        //Save the document to PostScript 
        document.saveToFile("ToPostScript.ps", FileFormat.Post_Script);
    }
}

Java: Convert Word to PostScript

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.