Free Java API to Create & Convert PPTX Presentation
A Powerful Open Source Java Solution to Create, Read, Edit, Manipulate, and Convert Microsoft Presentation Files in Java applications.
What is DOCX4J ?
DOCX4J is a JAXB-based, open-source Java library that serves as a powerful alternative to Microsoft's OpenXML SDK, specifically designed for working with Office Open XML formats. This robust library enables developers to read, write, edit, and save PowerPoint (PPTX) files with exceptional precision and flexibility. Beyond basic document handling, DOCX4J provides extensive capabilities for formatting text and paragraphs, inserting tables and images, and managing form elements within presentations. Its comprehensive feature set ensures that if the Office Open XML format supports a particular functionality, DOCX4J's API can implement it—making it ideal for dynamic document generation, enterprise reporting, and automated Office file processing in Java applications.
What sets DOCX4J apart is its deep-level document manipulation capabilities, allowing developers to modify slide layouts, apply complex formatting, embed multimedia, and even handle digital signatures. The library also supports advanced features like mail merge, PDF conversion, and document comparison, making it a versatile tool for business automation. Unlike simpler Office manipulation tools, DOCX4J gives developers fine-grained control over every element of a PPTX file, from slide transitions to embedded fonts. Whether you're building a document management system, a report generator, or a batch processing tool, DOCX4J provides the power and flexibility needed to work with Office files programmatically—all without requiring Microsoft Office to be installed.
Getting Started with DOCX4J
First of all, you need to have the Java Development Kit (JDK) installed on your system. Referencing DOCX4J in your Maven-based Java project is even simpler. All you need is to add the following dependency in your pom.xml and let your IDE fetch and reference the DOCX4J Jar files.
DOCX4J Maven Dependency
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-JAXB-Internal</artifactId>
<version>8.0.0</version>
</dependency>
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-JAXB-ReferenceImpl</artifactId>
<version>8.0.0</version>
</dependency>
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-JAXB-MOXy</artifactId>
<version>8.0.0</version>
</dependency>
Generate & Modify PPTX using Java
DOCX4J allows adding slides, specifying a layout for new slide, adding title and contents, inserting images and shapes, etc. Once done you can change the name of the existing presentation as well as can save it to the location of your choice.
How to Generate PPTX using DOCX4J - Java?
// Create package
PresentationMLPackage presentationMLPackage = PresentationMLPackage.createPackage();
// Create main presentation
MainPresentationPart pp = (MainPresentationPart) presentationMLPackage.getParts().getParts().get(new
PartName("/ppt/presentation.xml"));
// Create slide layout
SlideLayoutPart layoutPart = (SlideLayoutPart)
presentationMLPackage.getParts().getParts()
.get(new PartName("/ppt/slideLayouts/slideLayout2.xml"));
// Save presentation
presentationMLPackage.save(new File("FileFormat.pptx"));
Extract & Manipulate Slides using Java API
DOCX4J enables the software programmers to create & extract slides from PPTX file format. Software programmers can add a slide to an existing presentation with ease. Every slide in a presentation is based on a slide layout. lide layout is like a template for a slide, it allows users to inherit formatting choices, text boxes, titles or graphics, etc.
Manipulating Charts using DOCX4J
The open source DOCX4J library provides the specialized class to add a single-series column chart, multi-series chart, bubble chart, Line chart, pie charts & many more.