Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
202d1c8b34
commit
5640987b14
+13
-1
@@ -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<Block>((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;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user