fix(documents): Logo im PDF und umbrochene Namen im Vertragskopf
- app/pdf.php: PdfDoc::image() kann jetzt auch PNG (8 Bit, ohne Palette, nicht interlaced, inkl. Alphakanal über /SMask); PNG-Zeilenfilter 0–4 und Paeth werden rückgängig gemacht, RGB und Alpha als FlateDecode eingebettet. JPEG-Weg (Unterschrift) unverändert. - app/documents.php: document_pdf_title() setzt das Drink-it-cold-Logo oben rechts (web/assets/img/logo-drink-it-cold-480.png, Fallback 720er-Version). - app/documents.php: document_pdf_parties() bricht Mieter- und Vermietername auf die jeweilige Spaltenbreite um; Adressblock und Rückgabewert richten sich an der längeren Namenszeile aus, nichts läuft mehr in die Nachbarspalte.
This commit is contained in:
parent
8f45f756c0
commit
a755e7af81
2 changed files with 223 additions and 22 deletions
|
|
@ -298,10 +298,26 @@ function document_pdf_footer(PdfDoc $pdf, string $label): void
|
|||
$pdf->text(50, $h - 38, 7.5, 'Seite ' . $pdf->pageNo(), false, 'right', $w - 100);
|
||||
}
|
||||
|
||||
/** Kopfzeile mit Titel und rechtsstehender Kennung. */
|
||||
/** Logo-Datei für die PDF-Kopfzeile (PNG mit Transparenz) oder null. */
|
||||
function document_logo_path(): ?string
|
||||
{
|
||||
foreach (['/web/assets/img/logo-drink-it-cold-480.png', '/web/assets/img/logo-drink-it-cold.png'] as $candidate) {
|
||||
if (is_file(DIC_ROOT . $candidate)) {
|
||||
return DIC_ROOT . $candidate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Kopfzeile: Logo oben rechts, Titel links, Kennung rechts über der Linie. */
|
||||
function document_pdf_title(PdfDoc $pdf, string $title, string $right): void
|
||||
{
|
||||
$w = $pdf->pageWidth();
|
||||
$logo = document_logo_path();
|
||||
if ($logo !== null) {
|
||||
// Seitenverhältnis des Logos 480:267 – Breite 54 pt, Höhe passend.
|
||||
$pdf->image($logo, $w - 50 - 54.0, 22.0, 54.0, 30.0);
|
||||
}
|
||||
$pdf->text(50, 66, 20, $title, true);
|
||||
$pdf->text(50, 66, 8.5, $right, false, 'right', $w - 100);
|
||||
$pdf->line(50, 76, $w - 50, 76, 1.0);
|
||||
|
|
@ -320,8 +336,16 @@ function document_pdf_parties(PdfDoc $pdf, float $top, array $booking): float
|
|||
$pdf->text($right, $top, 7.5, 'VERMIETER', true);
|
||||
|
||||
$y = $top + 14;
|
||||
$pdf->text($left, $y, 11, (string) $booking['customer_name'], true);
|
||||
$pdf->text($right, $y, 11, $owner, true);
|
||||
// Lange Firmennamen umbrechen, damit sie nicht in die rechte Spalte laufen.
|
||||
$nameLines = $pdf->wrap((string) $booking['customer_name'], 11, $right - $left - 24, true);
|
||||
$ownerLines = $pdf->wrap($owner, 11, $pdf->pageWidth() - 50 - $right, true);
|
||||
foreach ($nameLines as $i => $line) {
|
||||
$pdf->text($left, $y + $i * 13, 11, $line, true);
|
||||
}
|
||||
foreach ($ownerLines as $i => $line) {
|
||||
$pdf->text($right, $y + $i * 13, 11, $line, true);
|
||||
}
|
||||
$y += (max(count($nameLines), count($ownerLines)) - 1) * 13;
|
||||
$pdf->text($right, $y + 13, 9.5, (string) $legal['business_name']);
|
||||
|
||||
$customer = array_values(array_filter([
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue