From 5640987b140d14dd9175dc28b9cc1aed2b977bd0 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 18:52:58 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/lib/pdf-pleading.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lib/pdf-pleading.ts b/src/lib/pdf-pleading.ts index f2db8bd..d6a55cc 100644 --- a/src/lib/pdf-pleading.ts +++ b/src/lib/pdf-pleading.ts @@ -244,10 +244,21 @@ export async function downloadPleadingPdf(input: PleadingInput, filename: string y += LINE_H * 1.5; } - const blocks = input.bodyHtml && input.bodyHtml.trim() + setFont(pdf, {}); // reset to non-bold for body + const blocks: Block[] = input.bodyHtml && input.bodyHtml.trim() ? htmlToBlocks(input.bodyHtml) : (input.body || "").split("\n").map((line) => ({ kind: "para", align: "left", tokens: [{ text: line, style: {} }] })); + if (blocks.length === 0 && input.bodyHtml) { + // Fallback: strip HTML tags and render as plain text paragraphs + const plain = input.bodyHtml + .replace(/<\/?(p|div|h[1-6]|li|br)[^>]*>/gi, "\n") + .replace(/<[^>]+>/g, ""); + plain.split(/\n+/).filter((l) => l.trim()).forEach((line) => { + blocks.push({ kind: "para", align: "left", tokens: [{ text: line, style: {} }] }); + }); + } + for (const block of blocks) { if (block.kind === "spacer" || block.kind === "rule") { y += LINE_H; continue; } @@ -276,6 +287,7 @@ export async function downloadPleadingPdf(input: PleadingInput, filename: string if (lines.length === 1 && lines[0].length === 0) { y += LINE_H; continue; } lines.forEach((line, i) => { ensureSpace(LINE_H); + setFont(pdf, {}); // reset per-line so prior block styling never bleeds in drawLine(pdf, line, x, y, block.align, maxW, i === lines.length - 1); y += LINE_H; });