Document settings — PHPRtfLite v1.x documentation

### Navigation

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

# Document settings

## Page orientation

You can use between `landscape` and `portrait` (default) page orientation.

    <?php
    // rtf document instance
    $rtf = new PHPRtfLite();
    // landscape page orientation
    $rtf->setLandscape();

## Page margins

You can set margins for the document and for sections, too. Section margins will overwrite document margins.

    <?php
    $rtf = new PHPRtfLite();
    // margin left: 1cm
    $rtf->setMarginLeft(1);
    // margin right: 2cm
    $rtf->setMarginRight(2);
    // margin top: 3cm
    $rtf->setMarginTop(3);
    // margin bottom: 4cm
    $rtf->setMarginBottom(4);

The code example below does the same in a shorter way.

    <?php
    $rtf = new PHPRtfLite();
    // margins: left 1cm, top 3cm, right 2cm, bottom 4cm
    $rtf->setMargins(1, 3, 2, 4);

You can define that odd and even pages uses mirrored margins. Section margins can be mirrored, too, and will overwrite the document setting.

    <?php
    $rtf = new PHPRtfLite();
    // margin left: 2cm
    $rtf->setMarginLeft(2);
    // margin right: 1cm
    $rtf->setMarginRight(1);
    // odd pages: left 2cm, right 1cm
    // even pages: left 1cm, right 2cm
    $rtf->setMirrorMarings();

## Page size

The paper width and height can be set for sections, too, which will overwrite the document settings.

    <?php
    $rtf = new PHPRtfLite();
    $rtf->setPaperWidth(14);  // in cm
    $rtf->setPaperHeight(25); // in cm

### Units in RTF

RTF uses TWIP (“TWentieth of an Inch Point” - 1/20 Point = 1/1440 Inch) [1] as internal unit. PHPRtfLite uses centimeter as default unit for all measuring unit inputs.

    <?php
    PHPRtfLite_Unit::setGlobalUnit(PHPRtfLite_Unit::UNIT_CM);    // inputs used as centimeters
    PHPRtfLite_Unit::setGlobalUnit(PHPRtfLite_Unit::UNIT_INCH);  // inputs used as inches
    PHPRtfLite_Unit::setGlobalUnit(PHPRtfLite_Unit::UNIT_POINT); // inputs used as points

[1] | http://en.wikipedia.org/wiki/Twip

### Character set (text input)

    <?php
    $rtf = new PHPRtfLite();
    $rtf->setCharset('Latin1');  // use Latin1 instead of UTF-8

### Hyphenation

    <?php
    $rtf = new PHPRtfLite();
    $rtf->setHyphenation();

### Navigation

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