Hello world

We'll create a simple document, with the message "Hello World!!" in it.

First, include this file "phpodt.php". It is the only file that you'll need to include.

include 'phpodt-0.3/phpodt.php'; //I assume you have the classes in the directory phpodt-0.3

Next, we create an instance of the ODT class. This class will take care of creating all the xml files for our odt document.

$odt = ODT::getInstance();

To add text, we need to create a paragraph first, represented by the Paragraph class.

$p = new Paragraph();

Then, we add the text to the paragraph.

$p->addText('Hello World!!');

Finally, we write the document to a file (helloworld.odt).

$odt->output('helloworld.odt');

Full example

include 'phpodt-0.3/phpodt.php';

$odt = ODT::getInstance();
$p = new Paragraph();
$p->addText('Hello World!!');
$odt->output('helloworld.odt');