diff --git a/lam/lib/3rdParty/tcpdf/fonts/dejavu/dejavuserif.ctg.z b/lam/lib/3rdParty/tcpdf/fonts/dejavu/dejavuserif.ctg.z new file mode 100644 index 000000000..c07840908 Binary files /dev/null and b/lam/lib/3rdParty/tcpdf/fonts/dejavu/dejavuserif.ctg.z differ diff --git a/lam/lib/lamtcpdf.inc b/lam/lib/lamtcpdf.inc index 9fbc7dcee..521421d06 100644 --- a/lam/lib/lamtcpdf.inc +++ b/lam/lib/lamtcpdf.inc @@ -58,7 +58,7 @@ class LamTcpdf extends Tcpdf { * @param string $fontName font name */ public function __construct($structure, $fontName) { - parent::__construct('mm', true, true); + parent::__construct('mm', true, false); $this->structure = $structure; $this->fontName = $fontName; // generic PDF information @@ -72,7 +72,7 @@ class LamTcpdf extends Tcpdf { * @inheritDoc */ public function defaultPageContent(int $pid = -1): string { - return ''; + return $this->addFooter(); } @@ -111,12 +111,31 @@ class LamTcpdf extends Tcpdf { /** * Adds the footer content + * + * @return string PDF output */ - public function addFooter(): void { - $this->SetY(-15); - $this->SetFont($this->fontName, '', LAMPDF_FONT_SIZE); + public function addFooter(): string { + $pid = $this->page->getPageId(); + $page = $this->page->getPage($pid); + $out = $this->graph->getStartTransform(); + $font = $this->font->insert($this->pon, $this->fontName, '', LAMPDF_FONT_SIZE); + $out .= $font['out']; + $prevcell = $this->defcell; + $this->defcell = $this::ZEROCELL; $footerText = _("This document was automatically created by LDAP Account Manager") . ' (' . getFormattedTime('Y-m-d H:i:s T') . ')'; - $this->Cell(0, 10, $footerText, 0, false, 'C', 0, '', 0, false, 'T', 'M'); + $out .= $this->getTextCell( + $footerText, + $this->toUnit($font['dw']), + $page['height'] - (2 * $this->toUnit($font['height'])), + $page['width'] - (4 * $this->toUnit($font['dw'])), + 0, + 0, + 0, + 'T', + ); + $out .= $this->graph->getStopTransform(); + $this->defcell = $prevcell; + return $out; } } diff --git a/lam/lib/pdf.inc b/lam/lib/pdf.inc index bc9ad80df..2005c39be 100644 --- a/lam/lib/pdf.inc +++ b/lam/lib/pdf.inc @@ -106,6 +106,7 @@ function createPdf($structure, $accounts, $pdfKeys, $account_type, $font, $retur include_once(__DIR__ . "/lamtcpdf.inc"); $pdf = new LamTcpdf($structure, $font); + $bbox = ['y' => 15, 'h' => 0]; $pageFormat = [ 'format' => 'A4', 'orientation' => 'P', @@ -117,9 +118,17 @@ function createPdf($structure, $accounts, $pdfKeys, $account_type, $font, $retur ] ]; - $pdf->font->insert($pdf->pon, $font, "B", LAMPDF_FONT_SIZE_BIG); + $font = $pdf->font->insert($pdf->pon, $font, "B", LAMPDF_FONT_SIZE_BIG); $pdf->addPage($pageFormat); - $pdf->addTextCell("TEST"); + for ($i = 0; $i < 50; $i++) { + $text = $pdf->getTextCell( + "$i Lorem ipsum dolor sit amet, consetetur sadipscing elitr.", + 15, + ($bbox['y'] + $bbox['h'] + $pdf->toUnit($font['ascent'])) + ); + $pdf->page->addContent($text); + $bbox = $pdf->getLastBBox(); + } /* $pdf = new LamTcpdf($structure, $font);