diff --git a/bericht_batch.php b/bericht_batch.php index 07e2f6e..8d1375f 100644 --- a/bericht_batch.php +++ b/bericht_batch.php @@ -60,14 +60,14 @@ if ($action === 'generate') { // Inhaltsverzeichnis-Seite $pdf->AddPage('P', 'A4'); - $pdf->SetFont('helvetica', 'B', 18); + $pdf->SetFont(bericht_ensure_hack_font(), 'B', 18); $pdf->Cell(0, 12, 'Bericht-Sammlung', 0, 1, 'C'); - $pdf->SetFont('helvetica', '', 11); + $pdf->SetFont(bericht_ensure_hack_font(), '', 11); $pdf->Cell(0, 8, 'Erstellt: '.dol_print_date(dol_now(), 'dayhour'), 0, 1, 'C'); $pdf->Ln(8); - $pdf->SetFont('helvetica', 'B', 13); + $pdf->SetFont(bericht_ensure_hack_font(), 'B', 13); $pdf->Cell(0, 8, 'Enthaltene Berichte ('.count($ids).')', 0, 1, 'L'); - $pdf->SetFont('helvetica', '', 10); + $pdf->SetFont(bericht_ensure_hack_font(), '', 10); $berichte = array(); foreach ($ids as $id) { diff --git a/bericht_card.php b/bericht_card.php index 96fccbc..d7a385a 100644 --- a/bericht_card.php +++ b/bericht_card.php @@ -499,7 +499,10 @@ if (!$bericht) { print ''; print '
…
— TCPDF kann das direkt + $pdf->SetFont(bericht_ensure_hack_font(), '', 9); + $pdf->SetTextColor(40, 40, 40); + // Border 0, kein Auto-Pagebreak damit die Notiz im reservierten Bereich bleibt + $autoPB = $pdf->getAutoPageBreak(); + $bMargin = $pdf->getBreakMargin(); + $pdf->SetAutoPageBreak(false, 0); + $pdf->writeHTMLCell($w, $h, $x, $y, $html, 0, 1, false, true, 'L', true); + $pdf->SetAutoPageBreak($autoPB, $bMargin); +} + function bericht_render_page_to_pdf($pdf, $page, $ori, $fmt, $fpdi_loaded) { - // Phase 6: Wenn der Editor ein Composite-PNG hochgeladen hat, nutzen wir das - // direkt — ein Bild über die ganze Seite. Keine Server-Shape-Logik nötig. + // Phase 6: Wenn der Editor ein Composite-PNG hochgeladen hat, nutzen wir das direkt if (!empty($page->composite_path)) { $full = bericht_resolve_data_path($page->composite_path); if ($full && file_exists($full)) { @@ -316,8 +370,14 @@ function bericht_render_page_to_pdf($pdf, $page, $ori, $fmt, $fpdi_loaded) $pageW = $pdf->getPageWidth(); $pageH = $pdf->getPageHeight(); $margin = 10; + // Notiz-Bereich reservieren wenn eine Notiz existiert + $note_h = 0; + if (!empty($page->note)) { + // ca. 1/4 Seite für HTML-Notizen, aber mindestens 20mm, max 80mm + $note_h = max(20, min(80, $pageH * 0.25)); + } $maxW = $pageW - 2 * $margin; - $maxH = $pageH - 2 * $margin - (empty($page->note) ? 0 : 10); + $maxH = $pageH - 2 * $margin - $note_h - ($note_h ? 4 : 0); list($iw, $ih) = @getimagesize($full); if ($iw && $ih) { $ratio = min($maxW / $iw, $maxH / $ih); @@ -327,9 +387,9 @@ function bericht_render_page_to_pdf($pdf, $page, $ori, $fmt, $fpdi_loaded) $pdf->Image($full, $x, $y, $w, $h); } if (!empty($page->note)) { - $pdf->SetY(-20); - $pdf->SetFont('helvetica', 'I', 9); - $pdf->MultiCell(0, 5, $page->note, 0, 'L'); + // Notiz direkt unter dem Bild rendern — kein SetY(-20), keine auto-Page-Break + $note_y = $margin + ($ih && $iw ? ($ih * min($maxW / $iw, $maxH / $ih)) : $maxH) + 4; + bericht_write_note_html($pdf, $page->note, $margin, $note_y, $maxW, $note_h); } return; } @@ -342,13 +402,13 @@ function bericht_render_page_to_pdf($pdf, $page, $ori, $fmt, $fpdi_loaded) $pdf->AddPage($ori, $fmt); $pageW = $pdf->getPageWidth(); $pageH = $pdf->getPageHeight(); - $pdf->SetFont('helvetica', 'B', 32); + $pdf->SetFont(bericht_ensure_hack_font(), 'B', 32); $pdf->SetTextColor(40, 40, 40); $pdf->SetY($pageH / 2 - 20); $pdf->MultiCell(0, 20, $page->title, 0, 'C'); if (!empty($page->note)) { $pdf->Ln(12); - $pdf->SetFont('helvetica', '', 12); + $pdf->SetFont(bericht_ensure_hack_font(), '', 12); $pdf->MultiCell(0, 8, $page->note, 0, 'C'); } return; @@ -364,7 +424,7 @@ function bericht_render_page_to_pdf($pdf, $page, $ori, $fmt, $fpdi_loaded) $margin = 10; $title_h = !empty($page->title) ? 12 : 0; if ($title_h) { - $pdf->SetFont('helvetica', 'B', 16); + $pdf->SetFont(bericht_ensure_hack_font(), 'B', 16); $pdf->SetY($margin); $pdf->MultiCell(0, $title_h, $page->title, 0, 'C'); } @@ -385,7 +445,7 @@ function bericht_render_page_to_pdf($pdf, $page, $ori, $fmt, $fpdi_loaded) $x0 = $margin + $slot * ($w_each + $gap); // Label - $pdf->SetFont('helvetica', 'B', 11); + $pdf->SetFont(bericht_ensure_hack_font(), 'B', 11); $pdf->SetXY($x0, $top); $pdf->Cell($w_each, $label_h, $label, 0, 0, 'C'); // Bild darunter @@ -397,9 +457,7 @@ function bericht_render_page_to_pdf($pdf, $page, $ori, $fmt, $fpdi_loaded) } bericht_burn_annotations($pdf, $page->fabric_json, 0, 0, $pageW, $pageH); if (!empty($page->note)) { - $pdf->SetY(-20); - $pdf->SetFont('helvetica', 'I', 9); - $pdf->MultiCell(0, 5, $page->note, 0, 'L'); + bericht_write_note_html($pdf, $page->note, 10, $pdf->getPageHeight() - 22, $pdf->getPageWidth() - 20, 18); } return; } @@ -416,7 +474,7 @@ function bericht_render_page_to_pdf($pdf, $page, $ori, $fmt, $fpdi_loaded) // Titel oben $title_h = 0; if (!empty($page->title)) { - $pdf->SetFont('helvetica', 'B', 16); + $pdf->SetFont(bericht_ensure_hack_font(), 'B', 16); $pdf->SetY(10); $pdf->MultiCell(0, 10, $page->title, 0, 'C'); $title_h = 14; @@ -443,9 +501,7 @@ function bericht_render_page_to_pdf($pdf, $page, $ori, $fmt, $fpdi_loaded) // Notiz unten if (!empty($page->note)) { - $pdf->SetY(-20); - $pdf->SetFont('helvetica', 'I', 9); - $pdf->MultiCell(0, 5, $page->note, 0, 'L'); + bericht_write_note_html($pdf, $page->note, 10, $pdf->getPageHeight() - 22, $pdf->getPageWidth() - 20, 18); } return; } @@ -489,9 +545,7 @@ function bericht_render_page_to_pdf($pdf, $page, $ori, $fmt, $fpdi_loaded) } if (!empty($page->note)) { - $pdf->SetY(-20); - $pdf->SetFont('helvetica', 'I', 9); - $pdf->MultiCell(0, 5, $page->note, 0, 'L'); + bericht_write_note_html($pdf, $page->note, 10, $pdf->getPageHeight() - 22, $pdf->getPageWidth() - 20, 18); } }