Getting Started

Add dependency

Add Underdocx as dependency to your project, for example in Maven extend your pom.xml:
<dependency>
    <groupId>io.github.winterrifier</groupId>
    <artifactId>underdocx</artifactId>
    <version>0.12.1</version>
</dependency>
When you use Gradle your dependency should look like this
implementation 'io.github.winterrifier:underdocx:0.12.1'
You can also visit Underdocx on Maven Central Repository.
to find more snippets how to include underdocx into your project.

Hello World Example

Now you can use this code to create a simple template that will be processed by the template engine:
public class HelloWorld {
  public static void main(String[] args) throws IOException {
    OdtContainer doc = new OdtContainer("Hello ${$name}");
    OdtEngine engine = new OdtEngine();
    engine.pushVariable("name", "World");
    engine.run(doc);
    File tmpFile = File.createTempFile("Test_", ".odt");
    doc.save(tmpFile);
    System.out.println("Document created: %s".formatted(tmpFile));
  }
}
This code will create a ODT-document with prefix "Test_" in your temp folder that contains text "Hello World"