* @copyright 2002-2026 Nicola Asuni - Tecnick.com LTD * @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE) * @link https://github.com/tecnickcom/tc-lib-pdf * * This file is part of tc-lib-pdf software library. */ // NOTE: local file reads (images, fonts, attachments) are restricted to an allowlist of // trusted paths that covers this package tree, so run the examples in place. To read assets // from other locations, list them in the 'allowedPaths' entry of the fileOptions constructor // parameter (see E047_remote_resources_security.php). // NOTE: run make fonts in the project root to generate the dependencies and example fonts. // autoloader when using Composer require __DIR__ . '/../vendor/autoload.php'; \define('OUTPUT_FILE', \realpath(__DIR__ . '/../target') . '/example_overview.pdf'); // define fonts directory \define('K_PATH_FONTS', \realpath(__DIR__ . '/../vendor/tecnickcom/tc-lib-pdf-font/target/fonts')); // autoloader when using RPM or DEB package installation //require ('/usr/share/php/Com/Tecnick/Pdf/autoload.php'); // main TCPDF object $pdf = new \Com\Tecnick\Pdf\Tcpdf( unit: \Com\Tecnick\Pdf\Page\Unit::Millimeter, isunicode: true, subsetfont: false, compress: true, mode: \Com\Tecnick\Pdf\PdfConformance::None, objEncrypt: null, ); // ---------- $pdf->setCreator('tc-lib-pdf'); $pdf->setAuthor('Nicola Asuni'); $pdf->setSubject('tc-lib-pdf example: 000'); $pdf->setTitle('tc-lib-pdf Visual Showcase'); $pdf->setKeywords('TCPDF tc-lib-pdf showcase barcode qr svg image transparency gradients'); $pdf->setPDFFilename('000_overview.pdf'); $pdf->setViewerPreferences(['DisplayDocTitle' => true]); $pdf->enableDefaultPageContent(); // ---------- // Insert fonts $titleFont = $pdf->font->insert($pdf->pon, 'dejavusans', 'B', 30); $subtitleFont = $pdf->font->insert($pdf->pon, 'dejavusans', '', 13); $bodyFont = $pdf->font->insert($pdf->pon, 'dejavusans', '', 10); $smallFont = $pdf->font->insert($pdf->pon, 'dejavusans', '', 8); $imgdir = __DIR__ . '/images'; // ---------- // Add first page $page01 = $pdf->addPage(); $pdf->setBookmark(name: 'Visual showcase', link: '', level: 0, page: -1, posx: 0, posy: 0, fstyle: 'B', color: 'blue'); $pageW = (float) $page01['width']; $pageH = (float) $page01['height']; $cardStyle = [ 'all' => [ 'lineWidth' => 0.35, 'lineCap' => 'butt', 'lineJoin' => 'miter', 'dashArray' => [], 'dashPhase' => 0, 'lineColor' => 'rgb(193,216,242)', 'fillColor' => 'rgb(255,255,255)', ], ]; $lineStyle = [ 'all' => [ 'lineWidth' => 0.25, 'lineCap' => 'butt', 'lineJoin' => 'miter', 'dashArray' => [], 'dashPhase' => 0, 'lineColor' => 'rgb(147,196,227)', 'fillColor' => 'rgb(147,196,227)', ], ]; $barcodeStyle = [ 'lineWidth' => 0, 'lineCap' => 'butt', 'lineJoin' => 'miter', 'dashArray' => [], 'dashPhase' => 0, 'lineColor' => 'black', 'fillColor' => 'black', ]; $textOnDark = $pdf->color->getPdfColor('rgb(244,250,255)'); $textOnLight = $pdf->color->getPdfColor('rgb(22,37,61)'); // Background atmosphere. $pdf->page->addContent($pdf->graph->getLinearGradient(0, 0, $pageW, $pageH, 'rgb(10,27,60)', 'rgb(0,171,193)', [ 0, 0, 1, 1, ])); $pdf->page->addContent($pdf->graph->getAlpha(0.12)); for ($lineY = -20; $lineY <= 330; $lineY += 12) { $pdf->page->addContent($pdf->graph->getLine(0, (float) $lineY, $pageW, (float) ($lineY + 95), $lineStyle)); } $pdf->page->addContent($pdf->graph->getAlpha(0.28)); $pdf->page->addContent($pdf->graph->getCircle(167, 46, 40, 0, 360, 'F', [ 'all' => [ 'lineWidth' => 0, 'lineCap' => 'butt', 'lineJoin' => 'miter', 'dashArray' => [], 'dashPhase' => 0, 'lineColor' => 'rgb(255,255,255)', 'fillColor' => 'rgb(255,255,255)', ], ])); $pdf->page->addContent($pdf->graph->getAlpha(1.0)); // Main title block. $pdf->page->addContent($textOnDark); $pdf->page->addContent($titleFont['out']); $pdf->addHTMLCell( html: '