fix: adjust table font size and improve cell content formatting in PDF generation
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 52s

This commit is contained in:
Torsten Schulz (local)
2026-07-17 15:51:15 +02:00
parent 110519c7b8
commit 91006bb0c5

View File

@@ -385,15 +385,20 @@ class PDFGenerator {
}
addTable(tableId, highlightName = '', excludeColumns = [], getCellPin = null) {
this.pdf.setFontSize(11);
const tableFontSize = 9.5;
this.pdf.setFontSize(tableFontSize);
// Wenn Spalten ausgeschlossen werden sollen, parse die Tabelle manuell
if (excludeColumns.length > 0) {
const table = document.querySelector(`#${tableId}`);
if (!table) return;
const headers = Array.from(table.querySelectorAll('thead th'))
const sourceHeaders = Array.from(table.querySelectorAll('thead th'))
.map((th, index) => ({ text: th.textContent.trim(), index }))
const timeColumnIndex = sourceHeaders.find((header) =>
/^(uhrzeit|zeit)$/i.test(header.text)
)?.index;
const headers = sourceHeaders
.filter(h => !excludeColumns.includes(h.index))
.map(h => h.text);
@@ -405,7 +410,12 @@ class PDFGenerator {
.filter(cell => !excludeColumns.includes(cell.index))
.map(cell => {
const pin = getCellPin ? getCellPin(sourceCells, cell.index) : null;
return pin ? { content: cell.text, pin } : cell.text;
// Die Webansicht ergänzt die übersetzte Einheit "Zeit". Im PDF
// ist die Spaltenüberschrift eindeutig, daher bleibt nur HH:MM.
const content = cell.index === timeColumnIndex
? cell.text.replace(/\s+(?:zeit|time)$/i, '')
: cell.text;
return pin ? { content, pin } : content;
});
});
@@ -414,7 +424,7 @@ class PDFGenerator {
body: rows,
startY: this.cursorY,
margin: { left: this.margin, right: this.margin },
styles: { fontSize: this.pdf.getFontSize(), cellPadding: 3, overflow: 'linebreak' },
styles: { fontSize: tableFontSize, cellPadding: 2.5, overflow: 'linebreak' },
headStyles: { fillColor: [220, 220, 220], textColor: 0, halign: 'left', fontStyle: 'bold' },
theme: 'grid',
tableWidth: 'auto',
@@ -453,7 +463,7 @@ class PDFGenerator {
} else {
this.pdf.text(pinText, data.cell.x + padding, pinY);
}
this.pdf.setFontSize(11);
this.pdf.setFontSize(tableFontSize);
this.pdf.setTextColor(0);
}
});