Example 6
Description
Here the NORMAL text style has been set to font family ‘Times’ and the base size is now 11 points. Because the other text styles base on the NORMAL style, they use these settings as well.
But it is also possible to adjust only some text styles to use other settings. In this example the table styles use now ‘Courier’ font family instead of ‘Times’. The FOOTER style gets a grey text color and the HEADER style will be printed in green.
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(); // Change NORMAL text style to use font family "Times" and set the size to 11 points $tsNormal = ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::NORMAL); $tsNormal->setFontFamily("Times"); $tsNormal->setSize(11.0); // Change the TABLE_? text styles to use font family "Courier" $ts = ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::TABLE_HEADER); $ts->setFontFamily("Courier"); $ts = ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::TABLE_ROW); $ts->setFontFamily("Courier"); $ts = ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::TABLE_TOTAL); $ts->setFontFamily("Courier"); $ts = ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::TABLE_SUBTOTAL); $ts->setFontFamily("Courier"); // Change the color of FOOTER and HEADER text styles $ts = ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::FOOTER); $ts->setTextColor("#CCCCCC"); $ts = ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::HEADER); $ts->setTextColor("#00CC00"); // Print example text with all predefined text styles - to show the adjustments made above $body->AddText("NORMAL (Times, 11 points)", ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::NORMAL)); $body->AddText("BOLD is the NORMAL style but bold font face", ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::BOLD)); $body->AddText("ITALIC is the NORMAL style but italic", ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::ITALIC)); $body->AddText("UNDERLINE is the NORMAL style but underlined", ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::UNDERLINE)); $body->AddText("SMALLNOMRMAL is the NORMAL style but one point smaller", ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::SMALLNORMAL)); $body->AddText("SMALLBOLD is the NORMAL style but one point smaller and bold face", ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::SMALLBOLD)); $body->AddText("HEADING1 is the NORMAL style but nine points taller and bold face", ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::HEADING1)); $body->AddText("HEADING2 is the NORMAL style but six points taller and bold face", ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::HEADING2)); $body->AddText("HEADING3 is the NORMAL style but three points taller and bold face and italic", ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::HEADING3)); $body->AddText("HEADING4 is the NORMAL style but one point taller and bold face and italic", ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::HEADING4)); $body->AddText("TABLE_HEADER is the NORMAL style but one point smaller and bold (courier!)", ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::TABLE_HEADER)); $body->AddText("TABLE_ROW is the NORMAL style but one point smaller (courier!)", ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::TABLE_ROW)); $body->AddText("TABLE_SUBTOTAL is the NORMAL style but one point smaller and italic (courier!)", ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::TABLE_SUBTOTAL)); $body->AddText("TABLE_TOTAL is the NORMAL style but one point smaller and bold (courier!)", ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::TABLE_TOTAL)); $body->AddText("FOOTER is the NORMAL style but one point smaller (grey!)", ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::FOOTER)); $body->AddText("HEADER is the NORMAL style but one point smaller (green!)", ReportLib\TextStyles::getTextStyle(ReportLib\TextStyles::HEADER)); // Produce the output of the report // uses the same params as TCPDF (F = File, I = Preview etc.) $report->output(__DIR__ . "/example_006.pdf", 'I');