diff --git a/index.html b/index.html index 6cfac27..9b83ae1 100644 --- a/index.html +++ b/index.html @@ -1684,7 +1684,7 @@ function updateTicker() { `⚠ ${x.r.region} — ${x.r.id_marche} : ${x.delai} jours restants` ).join(' • '); content.textContent = text; - const duration = Math.min(70, Math.max(25, Math.ceil(text.length / 14))); + const duration = Math.min(100, Math.max(30, Math.ceil(text.length / 18))); content.style.animationDuration = `${duration}s`; ticker.classList.add('active'); document.body.classList.add('has-ticker'); diff --git a/services/export-pdf.js b/services/export-pdf.js index a8d6ebe..007b1de 100644 --- a/services/export-pdf.js +++ b/services/export-pdf.js @@ -91,6 +91,13 @@ function kpiBox(doc, x, y, w, h, label, value, color) { // ─── Table ──────────────────────────────────────────────────────────────────── +function truncateToWidth(doc, text, maxWidth) { + if (doc.widthOfString(text) <= maxWidth) return text; + let t = text; + while (t.length > 1 && doc.widthOfString(t + '…') > maxWidth) t = t.slice(0, -1); + return t + '…'; +} + function table(doc, { title, headers, rows, colWidths }) { const pageW = doc.page.width - 80; const totalW = colWidths.reduce((a, b) => a + b, 0); @@ -111,7 +118,7 @@ function table(doc, { title, headers, rows, colWidths }) { doc.fontSize(7.5).font('Helvetica-Bold'); let x = 40; for (let i = 0; i < headers.length; i++) { - doc.text(headers[i], x + 3, y + 4, { width: widths[i] - 6, height: 11, ellipsis: true }); + doc.text(truncateToWidth(doc, headers[i], widths[i] - 6), x + 3, y + 4, { width: widths[i] - 6, lineBreak: false }); x += widths[i]; } y += 17; @@ -134,7 +141,7 @@ function table(doc, { title, headers, rows, colWidths }) { doc.fontSize(7).font('Helvetica'); let x = 40; for (let i = 0; i < row.length; i++) { - doc.text(String(row[i] ?? '—'), x + 3, y + 4, { width: widths[i] - 6, height: rowH - 4, ellipsis: true }); + doc.text(truncateToWidth(doc, String(row[i] ?? '—'), widths[i] - 6), x + 3, y + 4, { width: widths[i] - 6, lineBreak: false }); x += widths[i]; } stroke(doc, C.border);