$pages, 'filePath' => $filePath, 'options' => $options] ); $results = Factory::getApplication()->triggerEvent('onEBBeforeGeneratePDF', $eventObj); if (in_array(true, $results, true)) { return; } $title = $options['title'] ?? 'Invoice'; $pdf = static::getTCPDF($title, $options); foreach ($pages as $page) { $pdf->AddPage(); $pageOptions = !empty($page->options) ? $page->options : $options; if (!empty($pageOptions['bg_image'])) { static::setPageBackgroundImage($pdf, $pageOptions); } $pdf->writeHTML($page->content, true, false, false, false, ''); } $pdf->Output($filePath, 'F'); } protected static function getTCPDF($title, $options = []) { require_once JPATH_ROOT . '/components/com_eventbooking/tcpdf/config/tcpdf_config.php'; JLoader::register('TCPDF', JPATH_ROOT . '/components/com_eventbooking/tcpdf/tcpdf.php'); $options = new Registry($options); $config = EventbookingHelper::getConfig(); // Erstellung einer erweiterten TCPDF Klasse direkt "on the fly" $pdf = new class( $options->get('PDF_PAGE_ORIENTATION', PDF_PAGE_ORIENTATION), $options->get('PDF_UNIT', PDF_UNIT), $options->get('PDF_PAGE_FORMAT', PDF_PAGE_FORMAT), true, 'UTF-8', false ) extends TCPDF { // Diese Funktion wird von TCPDF automatisch am Ende jeder Seite aufgerufen public function Footer() { $this->SetY(-30); // 30mm von unten $this->SetFont('helvetica', '', 8); $footerHtml = '

GfSE - Hermann-Köhl-Straße 7 - 28199 Bremen - Deutschland
Weitere Unterstützung erhalten Sie von unserem Office: Tel.: +49 (0) 421 9896639-0

Bankverbindung: Kreissparkasse Waiblingen - IBAN: DE98 6025 0010 0015 1423 24 - BIC / Swift: SOLADES1WBN - USt-IdNr.: DE297177533

'; $this->writeHTML($footerHtml, true, false, true, false, ''); } }; $pdf->SetCreator($options->get('PDF_CREATOR', 'Events Booking')); $pdf->SetAuthor(Factory::getApplication()->get('sitename')); $pdf->SetTitle($title); $pdf->setPrintHeader(false); $pdf->setPrintFooter(true); // Wichtig: Footer aktivieren! $pdf->SetMargins( $config->get('pdf_margin_left', PDF_MARGIN_LEFT), $config->get('pdf_margin_top', 15), // Etwas mehr Platz oben $config->get('pdf_margin_right', PDF_MARGIN_RIGHT) ); $pdf->setFooterMargin(30); // Automatischer Seitenumbruch mit Puffer für den Footer $pdf->SetAutoPageBreak(true, 35); $font = empty($config->pdf_font) ? 'helvetica' : $config->pdf_font; $pdf->SetFont($font, '', 8); return $pdf; } protected static function setPageBackgroundImage($pdf, $options) { $options = new Registry($options); if ($options->get('bg_image')) { $backgroundImage = $options->get('bg_image'); $breakMargin = $pdf->getBreakMargin(); $autoPageBreak = $pdf->getAutoPageBreak(); $pdf->SetAutoPageBreak(false, 0); $pdf->Image($backgroundImage, $options->get('bg_left', ''), $options->get('bg_top', ''), $options->get('bg_width', 0), $options->get('bg_height', 0)); $pdf->SetAutoPageBreak($autoPageBreak, $breakMargin); $pdf->setPageMark(); } } }