The live demo starts when it’s in view.B and click a value: the box snaps to the phrase · T and click a row · drag a dashed column line · try the next receipt, then make the total follow its label
Map where each value sits on a PDF or a scan with a text layer, from nothing but its words and their boxes.
What it costs a frame
CPU
0.43 ms
02468101216.7 ms
GPU
not used
CPU, median
0.43 ms
CPU, 95th pct
0.77 ms
Draw calls
0
Weight
Light
Measured 13 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged CPU 0.42–0.47 ms). What ran: Measured with the demo editing itself: every frame it nudges the total’s box half a point (and back), so each frame reads the whole layout off the page again (four fields, a four-column table, the labels looked for) and repaints the boxes, the field list and the verdict; every 45 frames it swaps receipts, so the boxes follow their labels. Nothing runs while nothing changes. Phones: tiers are being measured next.
apple · Apple A19 Proin a browser tab · 16 November 2026
not timed
0.38
1.32
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 2026
not timed
0.49
0.92
Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.
What it needs
Renders with
DOM and CSSPlain DOM and CSS: every current browser.
Your browser
Runs hereNo WebGPU needed
Depends on
NothingNo other packages
What it’s for
Reading values off receipts, statements and forms that always look the same
Letting a person teach a layout by clicking the values on a sample
Line-item tables: rows and columns out of loose words
Pages that drift a little between printings or senders
Checking a layout against another page before it goes live
Turning highlights on a sample into fields
Pitfalls, in brief
Boxes are in page units (PDF points), origin top left, y down, on the page as it is shown (turned by its /Rotate). pdf.js and most PDF libraries give y up from the bottom, before the turn: convert once, when you build the words (runFromTransform, as the guide shows), never in the layout.
pdf.js gives text runs, not words. wordsFromRuns cuts them by character count, which is exact for monospaced text and close for most other text; a phrase or a column can come out a point or two off with wide letters.
A word belongs to a box when its centre is inside it.
A box with no anchor stays where it was drawn, so a page printed a line lower reads the wrong line or nothing.
An anchor is found by its whole words, ignoring case (its last word may carry a colon), within reach (300 points, |dx| + |dy|) of where it was on the sample; the nearest match wins.
5 more in brief
Columns follow the anchor sideways only.
Column types are guessed from the sample’s cells.
Tool keys (V, B, T, Esc) are heard on keyTarget, so set it to the editor’s whole screen; arrows and Delete act only with focus on the map, so they never move a box while someone types or uses a list beside it.
The layout keeps the sample’s positions.
Import field-map.base.css, then field-map.css (or your own look).
10 pitfalls in full, the hook-up guide, the module source and its tests come with the part.
Where it comes from
From My other apps. Fully custom code.
WAI-ARIA Authoring Practices Guide (W3C): the Window Splitter pattern for the column lines (a focusable separator with a value, moved by the arrow keys), and the Radio Group pattern for the demo’s tools
Instrument gauges in SVG (a tach with a red line on a nice scale, a speedometer with a best mark, a fuel gauge and an LED ring) whose needles chase their…