Getting started — PHPRtfLite v1.x documentation

### Navigation

- index
- next |
- previous |
- PHPRtfLite v1.x documentation »

# 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.

    <?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:

    <?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');

### Navigation

- index
- next |
- previous |
- PHPRtfLite v1.x documentation »