diff --git a/src/lib/docx-pleading.ts b/src/lib/docx-pleading.ts index 3b2fda7..e6aa9ac 100644 --- a/src/lib/docx-pleading.ts +++ b/src/lib/docx-pleading.ts @@ -302,6 +302,38 @@ export function buildPleadingDoc(input: PleadingInput): Document { input.body.split("\n").forEach((line) => bodyParagraphs.push(p(line))); } + // Signature block (above footnotes, after body) + const sig = input.signature; + if (sig && (sig.block?.trim() || sig.imageBytes)) { + bodyParagraphs.push(emptyP()); + bodyParagraphs.push(emptyP()); + if (sig.imageBytes) { + const data = + sig.imageBytes instanceof Uint8Array + ? sig.imageBytes + : new Uint8Array(sig.imageBytes); + bodyParagraphs.push( + new Paragraph({ + children: [ + new ImageRun({ + type: (sig.imageType as any) || "png", + data, + transformation: { width: 220, height: 70 }, + altText: { title: "Signature", description: "Attorney signature", name: "signature" }, + }), + ], + }), + ); + } else { + // Reserve vertical space for a wet signature + bodyParagraphs.push(emptyP()); + bodyParagraphs.push(emptyP()); + } + // Signature line (underscore rule, ~3 inches) + bodyParagraphs.push(p("_______________________________")); + sig.block.split("\n").forEach((line) => bodyParagraphs.push(p(line))); + } + // Footnotes rendered as endnote-style block at bottom of document const footnotes = (input.footnotes || []).filter((f) => f.text.trim().length > 0); if (footnotes.length > 0) {