.. _images:

Images
********************

In PHPRtfLite you can add images to headers and footers, to table cells, and sections.


Image resize
====================

You can specify the width and the height of the image in the RTF document. Note, that adding large images will cause large RTF documents, even if the images is scaled down by RTF.

.. code-block:: php

    <?php
    $imageFile = '/path/to/image/file';
    $image = $section->addImage($imageFile);
    // width to 1cm
    $image->setWidth(1);
    // height to 1cm
    $image->setHeight(1);


Image border
====================

.. code-block:: php

    <?php
    $border = new PHPRtfLite_Border(
        $rtf,                                       // PHPRtfLite instance
        new PHPRtfLite_Border_Format(2, '#00FF00'), // left border: 2pt, green color
        new PHPRtfLite_Border_Format(1, '#FFFF00'), // top border: 1pt, yellow color   
        new PHPRtfLite_Border_Format(2, '#FF0000'), // right border: 2pt, red color
        new PHPRtfLite_Border_Format(1, '#0000FF')  // bottom border: 1pt, blue color
    );
    // image with border
    $image->setBorder($border);

Read more about creating borders here: :ref:`borders`.