Rectangle

This document is about how to set up and use a Rectangle object.

Table of contents

First steps

Set up a Rectangle object and add it to a page object like that:

<?php 

use IDML\Content\Rectangle;

$rectangle = new Rectangle();

$page->addElement($rectangle);

If you want to set your own unique identifier, set up the Rectangle like that: new Rectangle('UniqueName');

Size and Position

Add a size and a position like that:

<?php

$rectangle
    ->setSize(100, 200)
    ->setPosition(10, 10)
;

Add Unit::MILLIMETERS as third parameter of each method if you prefer numbers in millimeters.

Adding an image

To add an image, you need to set up an Image object and add it then:

<?php

$rectangle->setImage($image);