XtremeDocumentStudio (for Java)
Next-generation multi-format document-processing component suite for Java SE/EE developers
Compatibility
Java 1.6 and later

How to convert DOCX files to PDF in Java

Learn to convert documents using XtremeDocumentStudio for Java.

Gnostice XtremeDocumentStudio (for Java) is the next-generation multi-format document-processing component suite for J2SE/J2EE developers. Currently, it supports viewing, printing, and converting PDF, DOCX, BMP, JPEG, PNG, JPEG2000 and single-page/multi-page TIFF. In this article, we will see how to convert documents.

The component to use for converting documents is com.gnostice.documents.DocumentConverter. You can pass the names of the input and output files and then DocumentConverter will automatically guess the input and output formats. DocumentConverter also has overloads with which you can specify the output format using a mime type. And, it also has overloads with which you read/write from/to streams and byte arrays.

import com.gnostice.core.XDocException;
import com.gnostice.documents.ConverterException;
import com.gnostice.documents.DocumentConverter;
import com.gnostice.documents.FormatNotSupportedException;

public class DocumentConversionDemo {  
  public static void main(String[] args) {
    DocumentConverter dc = new DocumentConverter();
    try {
      dc.convertToFile("./sample.docx", "./sample.pdf");
    } catch (FormatNotSupportedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (ConverterException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (XDocException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }    
  }
}

---o0O0o---

Our .NET Developer Tools
XtremeDocumentStudio .NET

Multi-format document-processing component suite for .NET developers.

PDFOne .NET

A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

Our Delphi/C++Builder developer tools
XtremeDocumentStudio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

Our Java developer tools
XtremeDocumentStudio (for Java)

Multi-format document-processing component suite for Java developers.

PDFOne (for Java)

A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications.

Our Platform-Agnostic Cloud and On-Premises APIs
StarDocs

Cloud-hosted and On-Premises REST-based document-processing and document-viewing APIs

Privacy | Legal | Feedback | Newsletter | Blog | Resellers © 2002-2017 Gnostice Information Technologies Private Limited. All rights reserved.