Example 21
Description
The first element has a left aligned text in a box with a width of 50mm.
Next the same text is in a box with a width of 120mm and a bold text style.
The third box is centered text in a box with a width of 40mm.
Last there is some justified text in a box with a width of 140mm and a thin border around it. The box has a left margin of 20mm and the text has a padding of 1mm to get some distance from the border
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 NORMAL text style $tsNormal = ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::NORMAL); $tsBold = ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::BOLD); // Text paragraph $text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.\n"; // Get ref to the report body $body = $report->getBody(); // Text in box $body->AddText("", $tsBold); $body->AddVDistance(5.0); $body->AddTextInBox(50.0, $text, $tsNormal); $body->AddVDistance(10.0); // Bold text in a wider box $body->AddTextInBox(120.0, $text, $tsBold); $body->AddVDistance(10.0); // Centered text in a box $body->AddTextInBox(40.0, $text, $tsNormal, 'C'); $body->AddVDistance(10.0); // Justified text in box with a border and a right margin $box = $body->AddBox(140.0, true, 0.1); $box->setMarginLeft(20.0); $box->setPadding(1.0); $box->AddText($text, $tsNormal, true, 'J'); $body->AddVDistance(10.0); // Produce the output of the report // uses the same params as TCPDF (F = File, I = Preview etc.) $report->output(__DIR__ . "/example_021.pdf", 'I');