Scanned PDF Optical Ingestion & Interactive SVG Vectorization¶
Multimodal Vision Transcription, Semantic Structure Recovery, and Exact Vector Reconstruction
Historical mathematical treatises such as Nathan Altshiller-Court’s College Geometry (1925 / 1952) combine dense synthetic reasoning, displayed algebraic proportions, italic and primed geometric notation, and compass-and-straightedge plates. This guide documents the canonical GEOMETOR Digital Scriptorium methodology for transforming archival PDF scans into an interactive, verifiable 2-Track Book Codex.
Important
Mandatory Rule — Multimodal Vision Over OCR
For PDFs with scanned pages—even when an embedded OCR text stream exists inside the PDF—agents must read the 300-DPI scan images directly (<NNNN>.png and <NNNN>.<gid>.png) using multimodal vision to ascertain semantic structure, prose, mathematical formulas, and diagram geometry. Never rely on embedded PDF OCR (`pdftotext`) for transcription or structural parsing.
Why Multimodal Vision Supersedes OCR on Mathematical Scans¶
Embedded OCR layers in scanned 19th- and 20th-century geometry books fail systematically on the exact constructs that carry mathematical meaning:
Formulas, Ratios, and Fractions: Displayed proportions such as
FL : FA = FQ : FP, stacked fractions like \(\tfrac{1}{2}\,\angle ABC\), radicals, and difference-of-squares identities (\(AM^2 - BM^2 = d^2\)) are routinely flattened, dropped, or misread by character-level OCR.Primes, Subscripts, and Compound Labels: Constructive geometry relies heavily on homologous point families—such as
A, A',T, T',P_1, P_2, and compound subscript-prime labelsP_1', P_2'(e.g., Figure 5 on folio0026)—as well as distinguishing circle centerOfrom0and angle\angle EfromL E.Typographic Semantic Hierarchy: Altshiller-Court encodes logical structure through typography: bold article headers (
13. Problem.), italicized enunciations, small-caps dialectical stages (ANALYSIS.,CONSTRUCTION.,PROOF.,DISCUSSION.,CONVERSELY.), multi-column exercise blocks (folio0039), and sentences flowing across side-by-side figures (folio0038, Figures 14 and 15). Reading the scan image directly preserves every structural boundary and mid-sentence page/figure continuation.Diagram Callouts & Visual Invariants: Optical inspection of
<NNNN>.pngreveals dashed auxiliary lines, tick marks on equal segments (Figure 17 on folio0040), center dots, and tangency contacts that cannot be inferred from text alone.
End-to-End Pipeline¶
1. Standardized 300-DPI Rasterization (ingest.py)¶
geometor.altshiller_court.ingest rasterizes all 334 PDF pages at 300 DPI via pdftoppm -png -r 300 and routes each <NNNN>.png scan into its structural chapter directory (00_frontmatter through 12_index) governed by resources/college_geometry/structure_map.json. Body and backmatter folios obey the unbroken pagination invariant:
2. Optical Transcription & Diplomatic Verification (<NNNN>.rst)¶
Each folio scan <NNNN>.png is inspected directly via multimodal vision and transcribed verbatim into <NNNN>.rst with:
YAML/field-list provenance metadata (
:folio:,:page:,:book:,:section:,:title:,:status:).Exact LaTeX math (
:math:and.. math::) verified glyph-by-glyph against the scan.Scholarly apparatus links (
:person:,:cite:,:term:) and companion constructive commentary in<NNNN>.notes.rst.
3. Calibrated Figure Cropping & Semantic SVG Compilation (graphics.py & svg_compiler.py)¶
For every folio containing geometric plates:
Crop Extraction:
<NNNN>.jsonrecords tight 300-DPI[x, y, w, h]bounding boxes;graphics.pynormalizes paper tone to pure white#ffffffand outputs<NNNN>.<gid>.pngand.inverted.png.Declarative Euclidean Model (No Embedded Python Scripts): Inside
<NNNN>.json, each graphic entry stores a declarative"geometry"dictionary (svg_scale: 0.5, exact point coordinates, letterpress glyph centroidslabel_x/label_y, and typedsegment,circle,arc,polygon, andangleelements) plus"svg_file": "<NNNN>.<gid>.svg". Nopy_filescripts are embedded in the treatise workspace.Interactive SVG Compilation:
svg_compiler.pycompiles each"geometry"model into an interactive<svg class="euclid-graphic" data-graphic-id="<NNNN>.<gid>">diagram compatible withphoton-platform/publishandgeometor_interactive.js.Quantitative & Visual Verification:
verify_svg_against_scanrasterizes visible vector strokes back onto the 300-DPI crop grid, requiring at least 95% pixel ink overlap (Chapter I achieves99.97%–100.00%across all 17 figures), followed by direct visual inspection of RGB overlays and standalone Inkscape renders.
4. Interactive Text-to-Diagram Wiring & Book Codex Compilation (compile_edition.py)¶
Folio transcriptions switch .. picture:: <NNNN>.<gid>.svg and wire:
:g:scoped geometric references (e.g.,:g:`(O, OE) <0038.g1:( O E )>`) highlighting points, lines, circles, arcs, polygons, and angle wedges on hover or click—including cross-folio references across page turns.:eq:equality assertions (e.g.,:eq:`BE = BA <0040.g1:/ B E / = 0040.g1:/ B A />`) activating dynamic green tick marks and angle arcs... enunciation::and.. assertion::blocks structuring problem statements, geometric loci, and deductive conclusions.
Finally, compile_edition.py de-paginates consecutive folios (reflowing mid-sentence page breaks and side-by-side figure splits) and copies all .svg assets into docsrc/college_geometry/ so publish build inlines crisp, theme-adaptive interactive SVGs into the published HTML codex.