mirror of
https://github.com/LDAPAccountManager/lam.git
synced 2025-10-06 03:49:56 +02:00
#368 new lib
This commit is contained in:
parent
a5aec1794f
commit
4acdb08e68
3 changed files with 36 additions and 8 deletions
BIN
lam/lib/3rdParty/tcpdf/fonts/dejavu/dejavuserif.ctg.z
vendored
Normal file
BIN
lam/lib/3rdParty/tcpdf/fonts/dejavu/dejavuserif.ctg.z
vendored
Normal file
Binary file not shown.
|
@ -58,7 +58,7 @@ class LamTcpdf extends Tcpdf {
|
||||||
* @param string $fontName font name
|
* @param string $fontName font name
|
||||||
*/
|
*/
|
||||||
public function __construct($structure, $fontName) {
|
public function __construct($structure, $fontName) {
|
||||||
parent::__construct('mm', true, true);
|
parent::__construct('mm', true, false);
|
||||||
$this->structure = $structure;
|
$this->structure = $structure;
|
||||||
$this->fontName = $fontName;
|
$this->fontName = $fontName;
|
||||||
// generic PDF information
|
// generic PDF information
|
||||||
|
@ -72,7 +72,7 @@ class LamTcpdf extends Tcpdf {
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function defaultPageContent(int $pid = -1): string {
|
public function defaultPageContent(int $pid = -1): string {
|
||||||
return '';
|
return $this->addFooter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,12 +111,31 @@ class LamTcpdf extends Tcpdf {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the footer content
|
* Adds the footer content
|
||||||
|
*
|
||||||
|
* @return string PDF output
|
||||||
*/
|
*/
|
||||||
public function addFooter(): void {
|
public function addFooter(): string {
|
||||||
$this->SetY(-15);
|
$pid = $this->page->getPageId();
|
||||||
$this->SetFont($this->fontName, '', LAMPDF_FONT_SIZE);
|
$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') . ')';
|
$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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,7 @@ function createPdf($structure, $accounts, $pdfKeys, $account_type, $font, $retur
|
||||||
include_once(__DIR__ . "/lamtcpdf.inc");
|
include_once(__DIR__ . "/lamtcpdf.inc");
|
||||||
|
|
||||||
$pdf = new LamTcpdf($structure, $font);
|
$pdf = new LamTcpdf($structure, $font);
|
||||||
|
$bbox = ['y' => 15, 'h' => 0];
|
||||||
$pageFormat = [
|
$pageFormat = [
|
||||||
'format' => 'A4',
|
'format' => 'A4',
|
||||||
'orientation' => 'P',
|
'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->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);
|
$pdf = new LamTcpdf($structure, $font);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue