Java API for PPTX Presentation Documents

Open Source solution to Create, Read, Edit and Convert Microsoft Presentation files in Java applications.

DOCX4J is similar to Microsoft's OpenXML SDK, but for Java. DOCX4J is JAXB-based open source(Apache v2) library for manipulating Microsoft Office file formats. It provides the functionality to read, write, edit and save Microsoft Office 2007 PPTX file format.

Using the API you can generate Presentation documents, edit them, format the text & paragraphs, insert tables & images and manage other form elements, and much more. Basically, its emphasis is on power, if the format supports it you can do it using the API.

Previous Next

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.

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

DOCX4J provides the specialized class to add a single-series column chart, multi-series chart, bubble chart, Line chart, pie charts & more.

 English