getting-started.txt 1000 Bytes
Getting started
***************

Autoloading
===============

You can choose if you want to use the PHPRtfLite autoloader or handle loading PHPRtfLite classes on your own. In most cases you are already using a class loading strategy and just need to add PHPRtfLite to it, which is recommended. For a quick start you may use the shipped PHPRtfLite autoloader.

.. code-block:: php

    <?php
    require_once '/path/to/your/library/PHPRtfLite.php';

    // registers PHPRtfLite autoloader (spl)
    PHPRtfLite::registerAutoloader();
    // rtf document instance
    $rtf = new PHPRtfLite();


Hello world example
===================

This is a short "Hello world" example:

.. code-block:: php

    <?php
    // rtf document instance
    $rtf = new PHPRtfLite();
    // add section
    $sect = $rtf->addSection();
    // write text
    $sect->writeText('Hello world!', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat());

    // save rtf document to hello_world.rtf
    $rtf->save('hello_world.rtf');