Work with Word Documents in Java

  Java DOCX

Work with Word Documents in Java

Open, create, edit, merge, split, compare and convert a Word document in Java. It's easy for Java developers to manipulate Microsoft Word documents.
Simply integrate our Cloud API into your Java applications to get full-featured Word API to handle documents. It supports all popular file formats such as DOCX, DOC, RTF, HTML, ODT, XPS, EPUB, etc.
File handling is an important part of any application. Java has several methods for creating, reading, updating and deleting files.
Java API offers methods which allow you to:

  • Convert DOCX, DOC, PDF, JPG, etc.
  • Perform the basic CRUD operations of creating, retrieving, updating and deleting documents.
  • Perform various Word operations.
  • Insert page numbers.
  • Append, convert and split documents.

Note: Java APIs libraries are hosted on Aspose repository.


  • Main
  • Convert
  • Structure
  • Content
  • Tables
  • MailMerge
  • Other
  • Plugins
  •  

Requirements

JDK 7 or higher

Supported Document Formats

You can both read and write documents in: DOCX, DOC, RTF, DOTX, DOT, ODT, OTT, XML, HTML, MHTML, TXT, PDF.
The write-only formats are: XPS, OpenXPS, PS, JPEG, PNG, BMP, SVG, TIFF, EMF, PCL, EPUB.
For more details, please check Supported File Formats.

Key features in Java

You can use API to perform different operations on Word documents such as inserting a table, adding paragraphs, extracting text, inserting an image, inserting a watermark image, getting hyperlinks and adding a header or a footer.
You can perform conversion operations for different file formats in Java such as:

  • Convert PDF to Word.
  • Convert Word to PDF.
  • Convert Word to TXT.
  • Convert Word to EPUB.
  • Convert DOCX to image.

Working with tables

You can use a table to structure content, place text or images in one cell and align it accordingly.
Furthermore, tables can be nested inside other tables up to any depth with Java API.
Working with tables includes many tasks such as:

  • Getting a list of tables that are contained in a Word document.
  • Inserting, updating, deleting and getting a table from a document.
  • Adding a table to a document.
  • Getting and updating table properties.
  • Getting, adding and deleting a table.
  • Getting, adding and deleting a table cell.
  • Extracting data from a table.

Working with Math objects

API allows you to get all Word Math objects that are defined in a document.
It includes many tasks such as getting and removing Objects from a Word document.

Working with Headers and Footers

API supports page headers and page footers.
This includes many tasks such as:

  • Accessing the header for a section.
  • Removing a header.
  • Adding a header.
  • Getting all headers and footers in a Word document.

Working with report generation and mail merge

Our API report generation and mail merge provide you with several tasks such as:

  • Using Word merge fields or Mustache.
  • Preparing DOCX templates to populate or other supported file formats.
  • Populating templates with data from JSON, XML.
  • Inserting HTML and images during mail merge.

Working with text

API allows you to find and replace text in DOCX and other documents in Java.
It has string searching and string matching algorithms to find all appearances of a character pattern, to find a place where one or many patterns are found within a larger string or text.
In other words, it finds substring matches inside a given string and finding dictionary strings that match the pattern defined by a regular expression.
You can replace all occurrences of a specified string with another string in Java.

Java API Installation

You can use Java API directly in your Maven Projects with simple configuration steps in pom.xml:

  1. Add Aspose Maven repository in repositories section.
  2. Define Java API dependency in dependencies section.

Prerequisites

  1. Go to the Aspose Cloud Dashboard, Create a new Account or Sign In to get App Key and App SID.
  2. Install Java 7 JRE/JDK or later versions on your computer.

Swagger UI

You can use Swagger UI to visualize and interact with APIs resources.

Advanced Features

How to open and edit a DOCX document in Java

  1. Add Java dependency.
  2. Go to the Aspose Cloud Dashboard.
  3. Create a new Account to access all applications and services or Sign In to your account.
  4. Click on My Apps tab to get App KEY and App SID.
  5. Upload a DOCX file to the Cloud Storage.
  6. Check Developer Guide to edit a DOCX file in Java.

Support and Learning Resources