Home Contact Us

Qoppa Software - PDF Tools & Libraries

Home / Contact Us

jWordConvert™ MS Word Document Conversion

Contents

Introduction
Getting Started
Convert To Images
Printing
Distribution and JAR files

Javadoc API
Source Code Samples

Introduction

jWordConvert is a Java library that can read Word documents and then convert to PDF, or render them into images or to a printer. jWordConvert can be integrated into your Java application or applet to allow you to provide conversion functionality to your users.jWordConvert provides the following functions:

  • Convert Word 97 documents to PDF
  • Set permissions and passwords on the converted PDF documents
  • Convert pages to JPEG, TIFF or PNG images (Coming in v1.1)
  • Print documents automatically (Coming in v1.1)
  • No third party software or drivers necessary
  • Support for JDK 1.4.2 and above
  • Save to the file system or to Java output streams

Like all of our libraries, jWordConvert is built using Qoppa's proprietary technology and so does not require any third party software or drivers.

Getting Started

The starting point for using jWordConvert is the com.qoppa.word.WordDocument class. This class is used to load Word documents and then provides methods to save as a PDF document, to convert to images and to print the document.

The class provides constructors to load Word documents from files, URLs, input streams or byte arrays. To load a Word file from the file system, there is only one line of code that is needed:

// Load the document
WordDocument wdoc = new WordDocument ("input.doc");

To save the document as a PDF file, use the following line:

// Save the document as a PDF file
wdoc.saveAsPDF ("output.pdf");

Converting to Images

Once a Word document has been loaded by instantiating the WordDocument class, pages in the document can converted to image files. jWordConvert can convert pages to JPEG, PNG and TIFF files.

// Save the first page to a PNG file
wdoc.savePageAsPNG (0, "page0.png", 150);

// Save the entire document as a TIFF file
TIFFOptions options = new TIFFOptions (150, TIFFOptions.TIFF_FAX_GROUP4);
wdoc.saveDocumentAsTIFF ("doc.tif", options);

Printing

jWordConvert can also print Word documents, the WordDocument class provides a number of print methods to allow printing to the default printer, to a named printer, or to prompt the user for the printer.

To print to the default printer, or to print to a named printer, use the following lines of code:

// Print to the default printer
wdoc.printToDefaultPrinter();

// Print to a named printer
wdoc.print ("my printer");

Distribution and JAR Files

jWordConvert is packaged in a single jar file, jwordconvert.jar that gets installed with the evaluation sample. When distributing an application that contains jWordConvert, the jwordconvert.jar file needs to be distributed along with it and needs to be included in the class path when running the application.

Javadoc API
Source Code Samples

Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.