Engineering Journal
Pdf Processor
Pdf Processor

Eight Architectural Moves That Fill the Empty Quadrant of Frontend PDF Extraction

2026-05-30

TLDR

Building a high-fidelity PDF extraction engine that runs entirely in the browser without server dependencies or ML model weights requires combining eight foundational architectural moves. Combining vector CTM baking, region-typed classification, underline filtering, topological cell merging, nearest-cell snapping, Web Worker isolation, per-page message streaming, and visual grid mapping fills the deterministic-structural-frontend niche.
Architectural MoveTechnical ResponsibilityPrimary Engineering Benefit
1. CTM-Baked VectorsReconstruct vector path primitivesReads table borders before text processing
2. Region-Typed ClassificationPre-assign text to single regionZero text item leakage by construction
3. Underline DiscriminationFilter baseline-adjacent H-linesEliminates 99% of phantom 1x1 tables
4. Topological Cell MergeQuery vertical line continuityEliminates fragile whitespace merge guesses
5. Nearest-Cell SnapEuclidean cell center snappingEliminates coordinate jitter data drops
6. Web Worker IsolationOff-thread pipeline executionMain thread UI stays 100% responsive
7. Per-Page StreamingStream per-page worker messagesPrevents structured clone postMessage crashes
8. Visual Grid MappingExport Cartesian cell arraysEnables instant matrix table editing

The eight foundational architectural moves

[PDF Stream] ---> [1. CTM Vectors] ---> [3. Underline Filter] ---> [2. Region Scoper]
                                                                        |
[Visual Grid Mapper] <--- [8. Grid Map] <--- [5. Nearest Snap] <--- [4. Topo Merge]

1. CTM-Baked vector segments

Walk the PDF page operator list (OPS.constructPath, OPS.transform), transforming path vertices through the Current Transformation Matrix (CTM) to extract normalized vector line segments in viewport screen coordinates.

2. Region-Typed classification

Enforce a structural invariant: every text item belongs to exactly one region. Mark claimed text in an assignedTextIndices bitset during table, heading, and list extraction passes.

3. Underline-vs-Border discrimination

Filter horizontal line segments that sit $0\text{ to }5\text{px}$ below text baselines before running lattice table reconstruction.
// Remove decorative underlines from table border candidate pool
if (yDist >= -1 && yDist <= 5 && isXSpanOverlapping(textItem, lineSegment)) {
  underlineSegmentSet.add(lineSegment.id);
}

4. Topological cell-merge inference

Determine table cell merging by checking vertical line segment presence across row coordinates rather than measuring visual text spacing.

5. Nearest-Cell Euclidean snapping

Snap scoped text items to cell centers within a $15\text{px}$ Euclidean radius, accommodating PDF coordinate jitter.

6. Web worker isolation

Execute PDF parsing, vector reconciliation, layout classification, and HTML assembly inside a dedicated Web Worker thread.

7. Per-Page message streaming

Stream incremental per-page result objects (type: 'page') from the Web Worker to prevent memory crashes on large documents.

8. Visual grid mapping integration

Map extracted HTML tables directly into VisualGridMapper Cartesian matrices for downstream web editor manipulation.
Rule of thumb: Combine vector operator parsing, single-region text scoping, and off-thread Web Worker execution to build deterministic browser PDF engines.
Read this post in the full Engineering Journal →