page 101

Java: Convert Word to PCL

2021-12-23 07:24:41 Written by Koohji

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>13.11.2</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.

Java: Convert Word to PostScript

2021-12-16 07:04:08 Written by Koohji

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>13.11.2</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.

Microsoft Word provides a real-time word counter that counts the number of words in a document when you type. Beyond that, Microsoft Word also counts the number of pages, paragraphs and characters with or without spaces. In this article, you will learn how to programmatically count the number of words or characters in an existing Word document 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>13.11.2</version>
    </dependency>
</dependencies>

Count the Number of Words in a Word Document

The detailed steps are as follows:

  • Create a Document instance.
  • Load a sample Word document using Document.loadFromFile() method.
  • Count the number of words using Document.getBuiltinDocumentProperties().getWordCount() method.
  • Count the number of characters without spaces using Document.getBuiltinDocumentProperties().getCharCount() method.
  • Count the number of characters with spaces using Document.getBuiltinDocumentProperties().getCharCountWithSpace() method.
  • Java
import com.spire.doc.*;
public class countWordsNumber {
    public static void main(String[] args) {
        //Create a Document instance
        Document document = new Document();

        //Load a sample Word document
        document.loadFromFile("Demo.docx");

        //Count the number of words
        System.out.println("WordCount: " + document.getBuiltinDocumentProperties().getWordCount());

        //Count the number of characters without spaces
        System.out.println("CharCount: " + document.getBuiltinDocumentProperties().getCharCount());

        //Count the number of characters with spaces
        System.out.println("CharCountWithSpace: " + document.getBuiltinDocumentProperties().getCharCountWithSpace());
    }
}

Java: Count the Number of Words in a Word Document

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.

page 101

Coupon Code Copied!

Christmas Sale

Celebrate the season with exclusive savings

Save 10% Sitewide

Use Code:

View Campaign Details