General

Components

Community

Development

TDF

ODFDOM - The OpenDocument API

ODFDOM is a free OpenDocument Format (ODF) library. Its purpose is to provide an easy common way to create, access and manipulate ODF files, without requiring detailed knowledge of the ODF specification. It is designed to provide the ODF developer community with an easy lightwork programming API portable to any object-oriented language.

The current reference implementation is written in Java (see JavaDocs online).

To learn more about the project's architecture, refer to the project overview and the ODFDOM Layers section.

With 0.10.0 the basics of collaboration functionality - the change/operation concept were added.

Quickstart

Put the odfdom.jar file in your classpath. If you use Maven than you just need to add the following dependency to your project pom.xml:

  <dependency>
    <groupId>org.odftoolkit</groupId>
    <artifactId>odfdom-java</artifactId>
    <!-- find latest versions: https://github.com/tdf/odftoolkit/releases -->
    <version>1.0.0</version>
  </dependency>

Note: You also need Apache Xerces-J as XML parser and DOM implementation as well.

Create a New Document

Start with the following sample code to create a simple text document:

    // Create a text document from a standard template
    // (empty documents within the JAR)
    OdfTextDocument odt = OdfTextDocument.newTextDocument();
    // Append text to the end of the document.
    odt.addText("This is my very first ODF test");
    // Save document
    odt.save("MyFilename.odt");

Load an Existing Document

To work on an existing document you can load it from your source:

    // Load an existing text document from local file
    OdfDocument odt = OdfDocument.loadDocument("MyFilename.odt");
    // Append or modify text....

More Examples:

Documentation

A good starting point is reading the project overview and the ODFDOM Layers will help you to get an overview over the ODFDOM package structure.

Access JavaDocs online or JavaDoc as bundle from the official Maven repository.

There are David's ODFDOM tutorials. You'll find an introduction as well as sample code for creating text and spreadsheet documents. (Note: The tutorials might not yet be adapted to the latest version).

When meeting with questions, check if FAQs can help you.

How to Participate

There are many ways to participate and we're always looking for contributors. Just on the ODF Toolkit Project and afterwards watch this project. Then you may want to start with reading and posting on the mailing lists or report bugs or write documentation.

If you're a developer, just dive into the development section. Here you find information on where to access the source code and how to set up a build environment.

Impressum (Legal Info) | Privacy Policy (Datenschutzerklärung) | Statutes (non-binding English translation) - Satzung (binding German version) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Apache License, v2.0. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License v2.0. “LibreOffice” and “The Document Foundation” are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy. LibreOffice was based on OpenOffice.org.