Fixed PDF font & caption style

X-Lovable-Edit-ID: edt-11c53c81-f35f-4e7e-9a1b-56301e337fc1
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-18 18:43:55 +00:00
co-authored by renee-png
4 changed files with 23 additions and 22 deletions
+7 -9
View File
@@ -6810,16 +6810,14 @@ const bolditalic_b64 =
"LUEtQRu6BAAEAAALK1mwDiNCsA8jQrASQ1i5GH47IRu6AagEAAALK1mwECNCsBEjQgEBKysrKysrKysrKysrKytzc3N0dHRzc3Nz" +
"c3Nzc3Nzc3Nzc15zXnN0dQErK3NzdHVzdHUAKysrKysrAEuwHlBYsANFaLgDakVosECLYLAgI0RZsAdFaLgDa0VosECLYLAiI0QA";
let registered = false;
export function registerBookmanFont(pdf: jsPDF) {
// Add to VFS once; jsPDF instances share the global file system.
if (!registered) {
pdf.addFileToVFS("BookmanOldStyle-Regular.ttf", regular_b64);
pdf.addFileToVFS("BookmanOldStyle-Italic.ttf", italic_b64);
pdf.addFileToVFS("BookmanOldStyle-Bold.ttf", bold_b64);
pdf.addFileToVFS("BookmanOldStyle-BoldItalic.ttf", bolditalic_b64);
registered = true;
}
// jsPDF's VFS is per-instance — must add files for every new pdf object
// before calling addFont, otherwise addFont throws
// "Font is not stored as string-data in vFS".
pdf.addFileToVFS("BookmanOldStyle-Regular.ttf", regular_b64);
pdf.addFileToVFS("BookmanOldStyle-Italic.ttf", italic_b64);
pdf.addFileToVFS("BookmanOldStyle-Bold.ttf", bold_b64);
pdf.addFileToVFS("BookmanOldStyle-BoldItalic.ttf", bolditalic_b64);
pdf.addFont("BookmanOldStyle-Regular.ttf", BOOKMAN_FAMILY, "normal");
pdf.addFont("BookmanOldStyle-Italic.ttf", BOOKMAN_FAMILY, "italic");
pdf.addFont("BookmanOldStyle-Bold.ttf", BOOKMAN_FAMILY, "bold");
+11 -11
View File
@@ -65,9 +65,9 @@ const noBorder = {
insideVertical: { style: BorderStyle.NONE, size: 0, color: "FFFFFF" },
};
const verticalLine = {
const captionLeftBorders = {
top: { style: BorderStyle.NONE, size: 0, color: "FFFFFF" },
bottom: { style: BorderStyle.NONE, size: 0, color: "FFFFFF" },
bottom: { style: BorderStyle.SINGLE, size: 8, color: "000000" },
left: { style: BorderStyle.NONE, size: 0, color: "FFFFFF" },
right: { style: BorderStyle.SINGLE, size: 8, color: "000000" },
};
@@ -252,19 +252,19 @@ export function buildPleadingDoc(input: PleadingInput): Document {
const plaintiffLines = (input.plaintiffs || "").split("\n").filter((l) => l.trim().length > 0);
const defendantLines = (input.defendants || "").split("\n").filter((l) => l.trim().length > 0);
// Left side of caption
// Left side of caption — all bold
const leftCells: Paragraph[] = [];
plaintiffLines.forEach((l) => leftCells.push(p(l)));
if (plaintiffLines.length === 0) leftCells.push(p(""));
plaintiffLines.forEach((l) => leftCells.push(p(l, { bold: true })));
if (plaintiffLines.length === 0) leftCells.push(p("", { bold: true }));
leftCells.push(emptyP());
leftCells.push(p("Plaintiff(s),"));
leftCells.push(p("Plaintiff(s),", { bold: true }));
leftCells.push(emptyP());
leftCells.push(p("v."));
leftCells.push(p("v.", { bold: true }));
leftCells.push(emptyP());
defendantLines.forEach((l) => leftCells.push(p(l)));
if (defendantLines.length === 0) leftCells.push(p(""));
defendantLines.forEach((l) => leftCells.push(p(l, { bold: true })));
if (defendantLines.length === 0) leftCells.push(p("", { bold: true }));
leftCells.push(emptyP());
leftCells.push(p("Defendant(s)."));
leftCells.push(p("Defendant(s).", { bold: true }));
const rightCells: Paragraph[] = [
p(`CASE NO.: ${input.caseNumber || ""}`, { bold: true }),
@@ -279,7 +279,7 @@ export function buildPleadingDoc(input: PleadingInput): Document {
children: [
new TableCell({
width: { size: 5400, type: WidthType.DXA },
borders: verticalLine,
borders: captionLeftBorders,
margins: { top: 80, bottom: 80, left: 0, right: 200 },
children: leftCells,
}),
+4 -1
View File
@@ -202,7 +202,7 @@ export async function downloadPleadingPdf(input: PleadingInput, filename: string
const plaintiffLines = (input.plaintiffs || "").split("\n").filter((l) => l.trim());
const defendantLines = (input.defendants || "").split("\n").filter((l) => l.trim());
setFont(pdf, {});
setFont(pdf, { bold: true });
const captionLeft: string[] = [];
if (plaintiffLines.length) captionLeft.push(...plaintiffLines); else captionLeft.push(" ");
captionLeft.push("");
@@ -223,7 +223,10 @@ export async function downloadPleadingPdf(input: PleadingInput, filename: string
const captionEndY = ly;
pdf.setLineWidth(0.6);
// Vertical divider between caption columns
pdf.line(MARGIN + leftColW + 12, captionStartY - LINE_H + 4, MARGIN + leftColW + 12, captionEndY);
// Bottom border under the left caption cell
pdf.line(leftX, captionEndY + 2, MARGIN + leftColW + 12, captionEndY + 2);
void rightColW;
y = captionEndY + LINE_H;
+1 -1
View File
@@ -298,7 +298,7 @@ function PleadingNewPage() {
</div>
<div className="mt-6 flex">
<div className="flex-1 pr-4 border-r border-black">
<div className="flex-1 pr-4 border-r border-b border-black font-bold">
<div className="whitespace-pre-line min-h-[1.5em]">{plaintiffs || " "}</div>
<div className="mt-3">Plaintiff(s),</div>
<div className="mt-3">v.</div>