Feature Library

Field map on a fixed-layout page

0.43 CPU ms
A still of the Field map on a fixed-layout page demo
Still
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

0.43 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.

On every machine it was measured on
MachineGPU msCPU msCPU p95
RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring toolnot timed0.430.77
apple · Apple A19 Proin a browser tab · 16 November 2026not timed0.381.32
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 2026not timed0.490.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

  1. Reading values off receipts, statements and forms that always look the same
  2. Letting a person teach a layout by clicking the values on a sample
  3. Line-item tables: rows and columns out of loose words
  4. Pages that drift a little between printings or senders
  5. Checking a layout against another page before it goes live
  6. Turning highlights on a sample into fields

Pitfalls, in brief

  1. 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.
  2. 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.
  3. A word belongs to a box when its centre is inside it.
  4. A box with no anchor stays where it was drawn, so a page printed a line lower reads the wrong line or nothing.
  5. 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
  1. Columns follow the anchor sideways only.
  2. Column types are guessed from the sample’s cells.
  3. 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.
  4. The layout keeps the sample’s positions.
  5. 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

pdffixed layoutword boxestext layerocrextractiontemplatesmappingbounding boxessnapphrasetable columnscolumn detectionanchorslabelslayout shiftpreviewvalidationreceiptsformsimportingestkeyboardtouch

Near it in the frame