font-family-key public $bericht_title = ''; public $bericht_company = ''; public $bericht_logo = ''; /** * Muss direkt nach der Konstruktion aufgerufen werden. */ public function berichtInit($title, $company, $logo_path) { $this->bericht_title = (string) $title; $this->bericht_company = (string) $company; $this->bericht_logo = (string) $logo_path; // TODO: Hack-Font später mit vorab-konvertierten TCPDF-Definitionen // einbinden. TCPDF::addTTFfont zur Laufzeit funktioniert für Hack // nicht (PostScript-Family-Kollision "hack" zwischen Regular/Bold/ // Italic → hack.php überschreibt sich selbst, SetFont-Fallbacks // brechen HTML-Rendering ab). Bis dahin: Standard-Helvetica. $this->hack_font_key = 'helvetica'; } public function Header() { $pageW = $this->getPageWidth(); $logo_w = 0; if ($this->bericht_logo && file_exists($this->bericht_logo)) { $info = @getimagesize($this->bericht_logo); if ($info && $info[0] && $info[1]) { $maxW = 40; $maxH = 18; $ratio = min($maxW / $info[0], $maxH / $info[1]); $w = $info[0] * $ratio; $h = $info[1] * $ratio; $this->Image($this->bericht_logo, $pageW - 10 - $w, 6, $w, $h); $logo_w = $w; } } $this->SetTextColor(40, 40, 40); $this->SetFont($this->hack_font_key, 'B', 13); $this->SetXY(10, 8); $textW = $pageW - 20 - $logo_w - 4; $this->Cell($textW, 6, $this->bericht_title, 0, 2, 'L'); if ($this->bericht_company) { $this->SetFont($this->hack_font_key, '', 9); $this->SetX(10); $this->Cell($textW, 5, $this->bericht_company, 0, 2, 'L'); } $this->SetDrawColor(180, 180, 180); $this->SetLineWidth(0.2); $this->Line(10, 27, $pageW - 10, 27); } public function Footer() { $this->SetY(-12); $this->SetFont($this->hack_font_key, '', 9); $this->SetTextColor(100, 100, 100); $txt = 'Seite '.$this->getAliasNumPage().' / '.$this->getAliasNbPages(); $this->Cell(0, 8, $txt, 0, 0, 'C'); } } class BerichtPdf extends TCPDF { use BerichtPdfTrait; } if (class_exists('\\setasign\\Fpdi\\Tcpdf\\Fpdi')) { class BerichtPdfFpdi extends \setasign\Fpdi\Tcpdf\Fpdi { use BerichtPdfTrait; } }