diff --git a/artifacts/api-server/src/lib/pdf-renderer.ts b/artifacts/api-server/src/lib/pdf-renderer.ts index 701ec357..61daefcf 100644 --- a/artifacts/api-server/src/lib/pdf-renderer.ts +++ b/artifacts/api-server/src/lib/pdf-renderer.ts @@ -482,6 +482,7 @@ type DrawOpts = { mapping: FamilyMapping; color?: string; lineHeight?: number; + maxY?: number; }; const BIDI_CONTROL_RE = /[\u200E\u200F\u200B\u202A-\u202E\u2066-\u2069]/g; @@ -652,6 +653,7 @@ function drawWrappingLine( }); let totalH = 0; for (const vl of lines) { + if (opts.maxY !== undefined && opts.y + totalH + lh > opts.maxY + 0.5) break; if (vl) drawBidiLine(doc, vl, { ...opts, y: opts.y + totalH }); totalH += lh; } @@ -986,6 +988,7 @@ export async function renderSchedulePdf(input: RenderPdfInput): Promise const rowBottom = rowTop + rowHeight; let cx = tableX; for (let i = 0; i < cells.length; i++) { + const savedCellY = doc.y; const c = cells[i]; const cellW = widths[i] - cellPadX * 2; const textLines = c.text.split("\n"); @@ -1006,9 +1009,11 @@ export async function renderSchedulePdf(input: RenderPdfInput): Promise mapping, color: input.font.fontColor, lineHeight, + maxY: rowBottom, }); y += used; } + doc.y = savedCellY; cx += widths[i]; } doc.y = rowTop + rowHeight;