Example 2

Description

An instance of a Report is created and the attributes are passed to the report. Therefore, a PageFormat instance is used to define the page format to ‘Letter’ in landscape mode. The margins are one inch on the top side and half an inch on all other sides.
To show the printable area a BoxFrame is added to the report body. The usage of BoxFrames can be found in a later example.

Output

<?php

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

use Adi\ReportLib as ReportLib;

// PageFormat for format letter, landscape with margins top = 1 inch and half an inch on the other sides
$pageFormat = new ReportLib\PageFormat("Letter", 'L', 25.4 / 2.0, 25.4,25.4 / 2.0,25.4 / 2.0);

// Create report instance with the pageFormat
$report = new ReportLib\Report($pageFormat);

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

// Create a box around the printable area
$box = $body->AddHBox(extent:0.1);
$box->setUseFullHeight(true);

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