TCPDF not found

Please ensure TCPDF is installed in the /tcpdf directory.

'); } require_once $tcpdfPath; $pdo = getDBConnection(); $settings = []; try { $result = $pdo->query("SELECT setting_key, setting_value FROM company_settings"); while ($row = $result->fetch()) { $settings[$row['setting_key']] = $row['setting_value']; } } catch (Exception $e) { die('Error loading settings.'); } $s = function($key, $default = '') use ($settings) { return $settings[$key] ?? $default; }; $addrParts = array_filter([ $s('company_address'), $s('company_city'), $s('company_state'), $s('company_country'), $s('company_pincode') ]); $fullAddr = implode(', ', $addrParts); // ─── Colors — all dark enough for reliable printing ─── $GREEN = [5, 150, 105]; $DARK = [15, 23, 42]; // near-black for primary text $BODY = [30, 41, 59]; // #1e293b — body text $SUB = [51, 65, 85]; // #334155 — secondary text (prints well) $MUTED = [71, 85, 105]; // #475569 — muted but still printable $RULE = [203, 213, 225]; // #cbd5e1 — lines $WHITE = [255, 255, 255]; class LetterheadPDF extends TCPDF { public function Header() {} public function Footer() {} } $pdf = new LetterheadPDF('P', 'mm', 'A4', true, 'UTF-8', false); $pdf->SetCreator('Relevant Reflex'); $pdf->SetAuthor($s('company_name', 'Relevant Reflex Consulting')); $pdf->SetTitle('Letterhead - ' . $s('company_name', 'Company')); $pdf->SetMargins(0, 0, 0); $pdf->SetAutoPageBreak(false, 0); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->AddPage(); $PW = 210; $PH = 297; $LM = 20; $RM = 20; $CW = $PW - $LM - $RM; // Left column width (company name area) — stops at 55% to avoid overlap $LEFT_W = $CW * 0.52; // Right column starts at 58% — gives a gap $RIGHT_X = $LM + ($CW * 0.58); $RIGHT_W = $PW - $RM - $RIGHT_X; // ══════════════════════════════════════════════════ // TOP ACCENT — thin green strip // ══════════════════════════════════════════════════ $pdf->SetFillColor(...$GREEN); $pdf->Rect(0, 0, $PW, 1.2, 'F'); // ══════════════════════════════════════════════════ // LOGO — rounded green square with "RR" // ══════════════════════════════════════════════════ $logoX = $LM; $logoY = 14; $logoS = 15; $pdf->SetFillColor(...$GREEN); $pdf->RoundedRect($logoX, $logoY, $logoS, $logoS, 3.2, '1111', 'F'); $pdf->SetFont('helvetica', 'B', 16); $pdf->SetTextColor(...$WHITE); $pdf->SetXY($logoX, $logoY + 3.2); $pdf->Cell($logoS, $logoS - 6.4, 'RR', 0, 0, 'C'); // ══════════════════════════════════════════════════ // COMPANY NAME (left side, constrained width) // ══════════════════════════════════════════════════ $nameX = $logoX + $logoS + 5; $nameMaxW = $LEFT_W - $logoS - 5; // available width for name $pdf->SetFont('helvetica', 'B', 22); $pdf->SetTextColor(...$GREEN); $pdf->SetXY($nameX, $logoY + 1); $pdf->Cell($nameMaxW, 10, $s('company_name', 'Your Company Name'), 0, 1, 'L'); // ══════════════════════════════════════════════════ // TAGLINE (left side, constrained) // ══════════════════════════════════════════════════ $pdf->SetFont('helvetica', '', 6.5); $pdf->SetTextColor(...$MUTED); $pdf->SetXY($nameX, $logoY + 12); $pdf->Cell($nameMaxW, 4, 'PANEL MANAGEMENT & RESEARCH SOLUTIONS', 0, 1, 'L'); // ══════════════════════════════════════════════════ // CONTACT INFO — right column, no overlap // ══════════════════════════════════════════════════ $contactItems = []; if ($s('company_phone')) $contactItems[] = $s('company_phone'); if ($s('company_email')) $contactItems[] = $s('company_email'); if ($s('company_website')) $contactItems[] = str_replace(['https://','http://'], '', $s('company_website')); $contactStartY = $logoY + 1; $contactLineH = 6.5; foreach ($contactItems as $i => $text) { $y = $contactStartY + ($i * $contactLineH); // Contact text — right-aligned within right column $pdf->SetFont('helvetica', '', 9); $pdf->SetTextColor(...$BODY); $pdf->SetXY($RIGHT_X, $y); $pdf->Cell($RIGHT_W, $contactLineH, $text, 0, 0, 'R'); } // ══════════════════════════════════════════════════ // ADDRESS // ══════════════════════════════════════════════════ $addrY = $logoY + $logoS + 7; $pdf->SetFont('helvetica', '', 9); $pdf->SetTextColor(...$SUB); $pdf->SetXY($LM, $addrY); $pdf->MultiCell($CW * 0.65, 4.5, $fullAddr, 0, 'L'); // ══════════════════════════════════════════════════ // HEADER DIVIDER — solid green line // ══════════════════════════════════════════════════ $divY = $addrY + 14; $pdf->SetDrawColor(...$GREEN); $pdf->SetLineWidth(0.5); $pdf->Line($LM, $divY, $PW - $RM, $divY); // ══════════════════════════════════════════════════ // FOOTER // ══════════════════════════════════════════════════ $footerY = $PH - 18; // Separator $pdf->SetDrawColor(...$RULE); $pdf->SetLineWidth(0.2); $pdf->Line($LM, $footerY, $PW - $RM, $footerY); // Footer left $pdf->SetFont('helvetica', '', 8); $pdf->SetTextColor(...$MUTED); $footerLeft = $s('company_name', 'Company'); if ($s('company_city') || $s('company_state')) { $footerLeft .= ' · ' . $s('company_city', ''); if ($s('company_state')) $footerLeft .= ', ' . $s('company_state'); } $pdf->SetXY($LM, $footerY + 4); $pdf->Cell($CW * 0.65, 5, $footerLeft, 0, 0, 'L'); // Footer right if ($s('company_website')) { $pdf->SetXY($LM + ($CW * 0.65), $footerY + 4); $pdf->Cell($CW * 0.35, 5, str_replace(['https://','http://'], '', $s('company_website')), 0, 0, 'R'); } // ══════════════════════════════════════════════════ // BOTTOM ACCENT — thin green strip // ══════════════════════════════════════════════════ $pdf->SetFillColor(...$GREEN); $pdf->Rect(0, $PH - 1.2, $PW, 1.2, 'F'); // ══════════════════════════════════════════════════ // OUTPUT // ══════════════════════════════════════════════════ $filename = 'Letterhead - ' . $s('company_name', 'Company') . '.pdf'; $pdf->Output($filename, 'D');