TCPDF not found

Please ensure TCPDF is installed in the /tcpdf directory.

'); } require_once $tcpdfPath; $pdo = getDBConnection(); // ─── Load company settings ─── $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; }; // ─── Tagline (2 lines). Override via DB keys if needed. ─── $tag1 = $s('company_tagline_line1', 'MARKET RESEARCH TECHNOLOGY &'); $tag2 = $s('company_tagline_line2', 'DATA COLLECTION SOLUTIONS'); // ─── Address built as 2 lines ─── $addrLine1 = $s('company_address'); $addrLine2Bits = array_filter([ $s('company_city'), trim($s('company_state') . ' ' . $s('company_pincode')), $s('company_country'), ]); $addrLine2 = implode(', ', $addrLine2Bits); // ─── Website cleaned of scheme ─── $websiteRaw = $s('company_website', 'relevantreflex.com'); $website = preg_replace('#^https?://#i', '', $websiteRaw); // ─── Color palette (mirrors the designed letterhead) ─── $BRAND = [5, 150, 105]; // #059669 — emerald $MUTED = [107, 114, 128]; // #6B7280 — gray-500 $HAIRLINE = [209, 213, 219]; // #D1D5DB — gray-300 $WATERMARK = [229, 231, 235]; // #E5E7EB — gray-200 $WHITE = [255, 255, 255]; // ─── PDF setup ─── 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(); // ─── Page geometry (mm) ─── $PW = 210; $PH = 297; $MX = 20; // left/right margin $RIGHT = $PW - $MX; // ===================================================================== // WATERMARKS — drawn first so they sit beneath the header/footer. // Vertical text in the side margins (x ≈ 9mm), well clear of the body // typing zone (x = 20–190mm). // ===================================================================== $pdf->SetFont('helvetica', 'B', 11); $pdf->SetTextColor(...$WATERMARK); $wmText = 'RELEVANT REFLEX CONSULTING'; // LEFT — three watermarks reading bottom-to-top foreach ([95, 170, 245] as $yPivot) { $pdf->StartTransform(); $pdf->Rotate(90, 9, $yPivot); $pdf->Text(9, $yPivot, $wmText); $pdf->StopTransform(); } // RIGHT — three watermarks reading top-to-bottom foreach ([45, 120, 195] as $yPivot) { $pdf->StartTransform(); $pdf->Rotate(-90, $PW - 9, $yPivot); $pdf->Text($PW - 9, $yPivot, $wmText); $pdf->StopTransform(); } // ===================================================================== // HEADER // ===================================================================== $logoX = $MX; $logoY = 18; $logoS = 16; // --- Logo: rounded emerald square with white "RR" centered --- $pdf->SetFillColor(...$BRAND); $pdf->RoundedRect($logoX, $logoY, $logoS, $logoS, 3, '1111', 'F'); $pdf->SetFont('helvetica', 'B', 14); $pdf->SetTextColor(...$WHITE); $pdf->SetXY($logoX, $logoY); $pdf->Cell($logoS, $logoS, 'RR', 0, 0, 'C', false, '', 0, false, 'T', 'M'); // --- Wordmark --- $wmX = $logoX + $logoS + 6; $pdf->SetFont('helvetica', 'B', 16); $pdf->SetTextColor(...$BRAND); $pdf->SetXY($wmX, $logoY + 1); $pdf->Cell(110, 7, $s('company_name', 'Relevant Reflex Consulting'), 0, 0, 'L'); // --- Tagline: 2 stacked lines, letter-spaced, muted gray --- $pdf->setFontSpacing(0.25); $pdf->SetFont('helvetica', '', 7.8); $pdf->SetTextColor(...$MUTED); $pdf->SetXY($wmX, $logoY + 8.5); $pdf->Cell(80, 3.5, $tag1, 0, 0, 'L'); $pdf->SetXY($wmX, $logoY + 12.2); $pdf->Cell(80, 3.5, $tag2, 0, 0, 'L'); $pdf->setFontSpacing(0); // --- Contact stack on the right (right-aligned to right margin) --- $contactY = $logoY + 1; $lineH = 5.2; $contactBoxW = $PW - 2 * $MX; $pdf->SetFont('helvetica', 'B', 10); $pdf->SetTextColor(...$MUTED); $pdf->SetXY($MX, $contactY); $pdf->Cell($contactBoxW, 5, $s('company_phone'), 0, 0, 'R'); $pdf->SetFont('helvetica', '', 10); $pdf->SetXY($MX, $contactY + $lineH); $pdf->Cell($contactBoxW, 5, $s('company_email'), 0, 0, 'R'); $pdf->SetTextColor(...$BRAND); $pdf->SetXY($MX, $contactY + 2 * $lineH); $pdf->Cell($contactBoxW, 5, $website, 0, 0, 'R'); // --- Header divider: short emerald accent + hairline --- $divY = $logoY + $logoS + 6; $pdf->SetDrawColor(...$BRAND); $pdf->SetLineWidth(0.6); // ≈ 1.6pt $pdf->Line($MX, $divY, $MX + 35, $divY); $pdf->SetDrawColor(...$HAIRLINE); $pdf->SetLineWidth(0.18); // ≈ 0.5pt $pdf->Line($MX + 35, $divY, $RIGHT, $divY); // ===================================================================== // FOOTER // ===================================================================== $accentY = $PH - 32; // accent line — well above the address $addr1Y = $PH - 23; // address line 1 $addr2Y = $PH - 19; // address line 2 $webY = $PH - 21; // website (right) — visually centered to address // Footer accent: hairline + brand on the right $pdf->SetDrawColor(...$HAIRLINE); $pdf->SetLineWidth(0.18); $pdf->Line($MX, $accentY, $RIGHT, $accentY); $pdf->SetDrawColor(...$BRAND); $pdf->SetLineWidth(0.6); $pdf->Line($RIGHT - 35, $accentY, $RIGHT, $accentY); // Address on left (2 lines) $pdf->SetFont('helvetica', '', 9); $pdf->SetTextColor(...$MUTED); $pdf->SetXY($MX, $addr1Y); $pdf->Cell(125, 4, $addrLine1, 0, 0, 'L'); $pdf->SetXY($MX, $addr2Y); $pdf->Cell(125, 4, $addrLine2, 0, 0, 'L'); // Website on right (vertically centered against the 2-line address) $pdf->SetFont('helvetica', 'B', 10); $pdf->SetTextColor(...$BRAND); $pdf->SetXY($MX, $webY); $pdf->Cell($contactBoxW, 5, $website, 0, 0, 'R'); // ===================================================================== // OUTPUT // ===================================================================== $filename = 'Letterhead - ' . $s('company_name', 'Company') . '.pdf'; $pdf->Output($filename, 'D');