chore(memory): LRN-009 — pre-rasterize then reserve text in pdf layout
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
2cfc49df04
commit
19c9c15979
2 files changed
+9
No files matched your search
@@ -64,3 +64,11 @@ Apply: any pdf-lib layout with variable-length user text. Always wrap explicitly
|
||||
|
||||
Times-22 ascender ≈ 17pt. Eyebrow size-9 baseline above title baseline needs ≥22pt gap to clear the ascender + leave ≥6pt visual breathing. Header rule needs ≥30pt cushion below for a size-22 title (title baseline at height-120ish on A4).
|
||||
Apply: any pdf-lib heading stack (eyebrow + title or chained headings). Compute from font.heightAtSize/widthOfTextAtSize, never eyeball pixel offsets.
|
||||
|
||||
---
|
||||
|
||||
## LRN-009 | 2026-05-19 | pdf-lib variable-count image layout — pre-rasterize, reserve text, then grid
|
||||
|
||||
Variable-count image blocks (N SVGs per observation) overflow page when stacked top-down because each item's height depends on its rasterized aspect ratio, unknown until after embedPng.
|
||||
Order: (1) pre-rasterize every image in parallel via Promise.all, capture aspect = img.height/img.width; (2) build text sections + estimate their height with wrapLines on real font metrics; (3) reserve bottom area = MARGIN_BOTTOM + textHeight + gap, derive availH for images; (4) pick cols (1 if single image, else 2), rows = ceil(n/cols); (5) rowBudget = (availH - rows*labelGap - (rows-1)*rowGap)/rows with a min-cell floor; (6) cellH per item = min(cellW*aspect, rowBudget) — preserves aspect, capped by budget.
|
||||
Apply: any pdf-lib page where image count is data-driven and text must remain visible. Never lay out images before measuring text; never embed-then-skip — embed all, then place. Min-cell floor prevents zero-height when content is dense.
|
||||
Reference in new issue
Block a user