Java: Convert Word to PCL

A PCL file is a digital printed document created in the Printer Command Language. It can be printed to HP LaserJet printers directly without having to be opened in an application. At some point, you might need to convert Word document to PCL. This article will introduce how to implement the conversion 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.10.3</version>
    </dependency>
</dependencies>
    

Convert Word to PCL

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

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

public class ConvertWordToPCL {
    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 PCL
        document.saveToFile("ToPCL.pcl", FileFormat.PCL);
    }
}

Java: Convert Word to PCL

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.