From 581e4ab6cfaccb7289fb5ed637751123c548d536 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 02:10:15 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/components/forms/custom-form-builder.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/components/forms/custom-form-builder.tsx b/src/components/forms/custom-form-builder.tsx index 0a9ec22..f1888df 100644 --- a/src/components/forms/custom-form-builder.tsx +++ b/src/components/forms/custom-form-builder.tsx @@ -456,7 +456,7 @@ export function CustomFormBuilder() { doc.setFontSize(fontSize); const lineH = fontSize * 1.4; - const drawTablePdf = (rows: string[][], hasHeader: boolean) => { + const drawTablePdf = (rows: TableCellSeg[][]) => { if (!rows.length) return; const cols = Math.max(...rows.map((r) => r.length)); const colW = maxW / cols; @@ -465,19 +465,24 @@ export function CustomFormBuilder() { const row = rows[ri]; // Compute row height based on tallest cell const cellLines = row.map((c) => - doc.splitTextToSize(applyVariables(c, ctx) || " ", colW - cellPad * 2), + doc.splitTextToSize(applyVariables(c.text, ctx) || " ", colW - cellPad * 2), ); const rowH = Math.max(...cellLines.map((l) => l.length)) * lineH + cellPad * 2; if (y + rowH > pageH - margin) { doc.addPage(); y = margin; } - // Draw cells for (let ci = 0; ci < cols; ci++) { const x = margin + ci * colW; - doc.setDrawColor(180); - doc.rect(x, y, colW, rowH); - const isHeader = hasHeader && ri === 0; + const cell = row[ci]; + const borders = cell?.borders ?? DEFAULT_BORDERS; + doc.setDrawColor(120); + doc.setLineWidth(0.5); + if (borders.t) doc.line(x, y, x + colW, y); + if (borders.b) doc.line(x, y + rowH, x + colW, y + rowH); + if (borders.l) doc.line(x, y, x, y + rowH); + if (borders.r) doc.line(x + colW, y, x + colW, y + rowH); + const isHeader = cell?.isHeader ?? false; doc.setFont(pdfFont, isHeader ? "bold" : "normal"); const lines = cellLines[ci] ?? [""]; let ty = y + cellPad + lineH * 0.8; @@ -493,7 +498,7 @@ export function CustomFormBuilder() { for (const seg of segments) { if (seg.kind === "table") { - drawTablePdf(seg.rows, seg.hasHeader); + drawTablePdf(seg.rows); continue; } const text = applyVariables(seg.text, ctx) || " ";