Example 20

Description

A BoxFrame is just a rectangular space in the report. It can be filled with any other frame type (e.g. text).
A box with no content wouldn’t be visible in the report, because it has no border by default. To make them visible in this example all boxes have a border.
The first example box has a width of 70mm and a height of 50mm and a thin red border.
The next example box has a width of 150mm and a height of 20mm and a thin red border. But the pens on the left and right side have been set to 5mm.
The last example box uses the full width of the frame and has a height of 10mm. It has a special border with different colors and line extents

Output

<?php

include_once "../src/Report.php";

use Adi\ReportLib as ReportLib;

// Create report instance
//  default format A4, portrait with margins left = 20mm, top = 10mm, right = 10mm and bottom = 10mm
$report = new ReportLib\Report();

// Get ref to the report body
$body = $report->getBody();

$box = new ReportLib\BoxFrame(70.0, 50.0, 0.1, "#FF0000");
$body->addFrame($box);
$body->AddVDistance(10.0);

$box = new ReportLib\BoxFrame(150.0, 20.0, 0.1, "#FF0000");
$box->getBorder()->getLeftPen()->setExtent(5.0);
$box->getBorder()->getRightPen()->setExtent(5.0);
$body->addFrame($box);
$body->AddVDistance(10.0);

$box = new ReportLib\BoxFrame(0.0, 10.0, 0.1, "#0000FF");
$box->setUseFullWidth(true);
$box->getBorder()->getTopPen()->setExtent(1.0);
$box->getBorder()->getLeftPen()->setExtent(1.0);
$box->getBorder()->getBottomPen()->setExtent(3.0);
$box->getBorder()->getBottomPen()->setColor("#FF00FF");
$box->getBorder()->getRightPen()->setExtent(3.0);
$box->getBorder()->getRightPen()->setColor("#FF00FF");
$body->addFrame($box);


// Produce the output of the report
//  uses the same params as TCPDF (F = File, I = Preview etc.)
$report->output(__DIR__ . "/example_020.pdf", 'I');