Example 19

Description

A table that has more lines that fit on one page will insert automatic page breaks (regarding the margins).
The header line will be repeated on every page. It is possible to suppress the repetition of the header. This example also shows the effect of an inter-row-space of 1mm

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();

// Add the table
$table = $body->AddTable();
$table->setInterRowSpace(1.0);

// Add four columns to the table
$table->addColumn("frametype", "Frame type", 40.0);
$table->addColumn("container", "Container type", 30.0, 'C');
$table->addColumn("description", "Description", 60.0);
$table->addColumn("number", "Number", 20.0, 'R');

// Add a data row to the table with the column widths
$row = new ReportLib\TableRow('D');
$row->setText("frametype", "40mm width");
$row->setText("container", "30mm width");
$row->setText("description", "60mm width");
$row->setText("number", "20mm width");
$table->addDataRow($row);

// Add 60 data rows to the table
for ($i = 0; $i < 60; $i++) {
    $row = new ReportLib\TableRow('D');
    $row->setText("frametype", "LineFrame");
    $row->setText("container", "No");
    $row->setText("description", "This frame type represents a line on the report.");
    $row->setText("number", $i + 1);
    $table->addDataRow($row);
}

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