SI Report Analyser

SI Report Analyser is a web app we built for a UK geoenvironmental practice whose staff were retyping contamination results from laboratory PDFs by hand. It finds the Certificates of Analysis in four lab formats, screens every value against the practice's limits and fills the export workbook, built on Next.js, TypeScript and pdf.js. It reads 156 of 156 hand-checked cells correctly on clean PDFs, and it refuses to export any value it cannot trace back to the page. It is in use at the practice.

Client build · United Kingdom · In use
Client
UK geoenvironmental practice (name withheld)
Sector
Contaminated land and site investigation
Status
Delivered, in use by the client
Our role
Design, build, evaluation and the gold test set
Input
Certificates of Analysis from i2 Analytical, Chemtest, SOCOTEC and Normec DETS, standalone or inside a full report
Output
Screening matrix, exceedance summary and an Excel import workbook
Stack
Next.js, React, TypeScript, pdf.js, Tesseract.js, ExcelJS, IndexedDB (Dexie), Vitest
Platform
Web app on Netlify; PDFs are processed in the browser

The problem

After a site investigation, soil samples go to an accredited laboratory. The results come back as Certificates of Analysis: dense PDF tables with one row per determinand (arsenic, lead, benzo(a)pyrene, the TPH carbon bands and dozens more), one column per sample, a unit, and often a detection limit written as <0.1 instead of a number. A consultant then compares every value with screening limits to decide what is contaminated and where the soil can go.

At our client, a UK geoenvironmental practice, that meant retyping. One report can hold more than a thousand results, in four laboratory house styles. On larger jobs the certificates sit as an appendix inside a ground investigation report of hundreds of pages, between borehole logs, drawings and geotechnical test sheets.

The errors are the dangerous kind. A dropped < turns "below the detection limit of 0.2" into "0.2". A value read from the next column belongs to a different sample, or a different depth in the same trial pit. So the brief was strict: every value that reaches the export must be the value printed on the certificate, for the right sample and depth, with its qualifier intact. Anything the software cannot prove goes to a person.

What we built

The SI Report Analyser is a web app with five working areas, from uploaded PDF to a filled export workbook.

Inbox: upload and locate

The user drops in a lab certificate or a whole ground investigation report. For a long report the app finds the certificates first (the outline, the contents page, then a jump scan of selected pages), shows a progress bar as it reads, and lists the page ranges it chose. If it finds no Certificate of Analysis it says so, and asks for the start page instead of producing an empty or invented table.

Screening matrix

Samples run across, determinands run down, and every cell is coloured against the active limit set: below, approaching (80% of the limit or more), exceeds, no limit, or unscreened. Values that came from OCR are underlined. Cells that need a typed value show the word enter instead of a number.

Source trace

Clicking any cell opens the PDF page with the exact word box highlighted, plus the raw line of text it came from. If a value could not be found on the page, the panel says "Not grounded in a source token" and the value is excluded from export. A person can correct a value here, and the correction is recorded as a human correction.

Limit sets

Two built-in limit sets come from the threshold document supplied for the project: a most-conservative set for the top metre and a set for general fill deeper than one metre. Users can clone either one and edit the thresholds per determinand.

Review queue and export

Before export, every result sits in one of three buckets: ready, needs action (disagreement, ungrounded, handwriting, low-confidence scan) or excluded (not on the import sheet, such as leachate tests or stone content). The export writes an Excel workbook in the fixed layout of the client's waste-stream import sheet: 47 rows from depth and moisture through asbestos, metals and organics, one column per sample. Cells that are not cleared stay blank. They are never filled with a best guess.

An exceedance summary lists each determinand over its limit, which samples exceed and the highest value.

About images on this page. We do not show screenshots of this product, because every screen shows the client's real lab data. The diagrams below are drawn from the source code, and every number quoted comes from the project's evaluation documents and test files.

How it works

A PDF does not contain a table. It contains drawing instructions: put this string at this x and y, in this font. What looks like a grid to a person is, to software, a few thousand loose words with coordinates. The whole pipeline exists to turn those loose words back into "this value is lead, in mg/kg, for sample TP3 at 0.50 m" and to prove each one.

1. PDF in 2. Locate the certificates 3. Text layer? Yes: pdf.js words No: OCR or page images 4. Rebuild the table from word positions Pass A: table extract Pass B: line cross-check 5. Ground every value, then compare A and B 6. Screen vs limit set 7. Review queue 8. Excel export a certificate, or a full report of several hundred pages outline titles, contents page, jump scan; rejects geotech and consultant appendices checked per page dashed = low-confidence path each word with x, y, width, height; high confidence when the passes agree Tesseract, or a cloud table API if configured; never auto-exported rows by vertical position, sample columns by horizontal position, wrapped names merged, depths attached, "<" joined to its number groups words into rows within 2.4 pt; this is the primary result re-reads the same words within 3.6 pt; only used to catch disagreement value must exist as a token on the page; disagreement blocks export below, approaching, exceeds a person decides the rest cleared cells only; others blank yes no
The extraction pipeline, drawn from the source. Dashed boxes are the low-confidence path for pages with no text layer: results from it are always marked and never exported without a person.

Words with coordinates, not tables

For each page, pdf.js returns every word with its position and size. The app sorts the words top to bottom and groups any words whose vertical position is within 2.4 points into one row. It then looks for the row that holds the sample IDs (patterns like TP1, BH01, WS301, including IDs split across two tokens), and records the horizontal position of each one. Those positions become the columns. Every value token in a determinand row is assigned to the nearest sample column, within a fixed distance, or to none.

Along the way it repairs what the PDF broke. A determinand name that wrapped onto a second line is merged back into its row. A < stored as its own word is joined to its number. Depth rows are attached to their sample columns, so the same trial pit at two depths becomes two samples. Method codes and accreditation marks (MCERTS, UKAS, lab method numbers) are stripped so they are never read as results.

Two passes and a grounding check

The primary pass produces cells: sample, determinand name, unit, raw value, page and word box. Every value is then grounded: the app searches the page's own tokens for that exact string, including a split < and number. A value that is not on the page is marked ungrounded and cannot be exported, so an invented number has no route into the workbook.

A second pass re-reads the same words with a looser row tolerance (3.6 points), and the two are compared cell by cell. Same value: agreed. Different plausible values: a disagreement, shown with both values and blocked until a person picks one.

Mapping, screening and data model

A lexicon of 55 determinand entries maps lab wording ("Arsenic (As)", "Total TPH >C6 to C40", "Chromium (VI)") to the rows of the export sheet. Each result stores a typed value, its source page and word box, the agreement status, a source class (clean text, scanned, rotated, handwritten) and a needs-human flag. Projects and corrections live in the browser's IndexedDB.

Hard problems and the decisions behind them

1. Lab PDFs that look like tables but are not

The obvious move is a PDF table tool. We measured two of them, PyMuPDF and pdfplumber, on the four lab formats. On the ruled i2 certificate they found 32 tables and 2,511 cells. On the borderless Chemtest certificate they found 2 tables and 4 cells across 9 pages. Tools that look for ruling lines see almost nothing when the columns are held together by white space alone.

The first approach in the codebase, one adapter per lab, was worse in a more dangerous way. Those adapters had no gold tests, and the measured output showed it: on Chemtest they recovered 12 results from 2 samples with the metals missing; on DETS they collapsed two columns for the same trial pit at different depths, so a result was read from the wrong depth; on i2 a cadmium result lost its <.

We chose one generic extractor driven by word positions, with no lab-specific parsing on the main path. It is the only option in our evaluation that recovered the borderless Chemtest metals and also scored 100% on the other three labs. Lab differences are handled as data (sample ID patterns, header words, method codes to strip), not as separate parsers.

There is a second kind of fake table: a consultant's "Screened Chemical Data" appendix, which looks like lab results but is not a laboratory certificate. Appendices of dashes are skipped. Grids with real units and values are extracted but flagged for review, because they are a compilation, not the lab's original. These rules have 15 tests of their own.

2. Finding the certificates inside a 1,000-page report

An earlier build passed every test on standalone certificates and still showed an empty table on unseen full reports. We traced it stage by stage instead of guessing. The locator trusted the first outline entry starting with "Certificates", which can be a set of geotechnical test certificates, and then never looked further. A 117 MB, 1,192-page report froze the tab, because pages were read on the main thread without yielding.

The fix was a separate locate step with hard budgets: outline titles, then the contents page, then a jump scan of at most 40 pages. On the 1,192-page report it reads at most 56 pages of full text before choosing the certificate start. A package now stops at the next non-certificate appendix, pages are read in chunks of 48, and the interface gets control back every 4 pages so the progress bar moves. Every parse records which stage failed (locate, classify, extract, join, map or export filter), so an empty result explains itself.

3. Scanned pages, and why we stopped trusting OCR

The client's pack contained no scanned certificates, so we made them: a clean 150 dpi raster, a page with 2.2 degrees of skew plus heavy JPEG compression and speckle, a page rotated 90 degrees, and a fax simulation, all of pages with known gold values. Then we ran Tesseract.js with deskew, denoise and contrast stretching.

Result: 0 of 105 gold cells assigned correctly. Tesseract read sample IDs like TP1 as noise, so no columns could be built, and the extractor correctly produced zero results instead of inventing columns. Preprocessing did not help: on the poor scan, raw number hits fell from 5 of 20 to 1 of 20 with it switched on. We wrote that down rather than claiming the opposite.

We also scored the OCR path against a public benchmark, a 40-table slice of RD-TableBench. Our Tesseract grid scored a mean similarity of 0.217, against published scores of 0.918 for Reducto, 0.857 for Azure Layout, 0.840 for AWS Textract and 0.797 for GPT-4o. That settled it: OCR is a last-resort word dump marked low confidence, never a source for the export. When a cloud table service is configured, scanned pages go to it as page images, and its values must pass the same grounding check.

4. Units, detection limits and "<0.1"

Every value is parsed into a typed result. <0.1 keeps its qualifier, stores 0.1 as the detection limit and is marked non-detect. Its display string stays <0.1 all the way to the export. It is never rounded to 0 or stripped to 0.1. > values keep their qualifier too. Asbestos text such as "NAD" or "Not detected" is a non-detect; a named fibre type such as chrysotile is a detection.

Screening a non-detect is conservative. The app compares the detection limit itself with the screening limit. If a lab's detection limit is higher than the limit, the cell is flagged as an exceedance, because "below 5" does not prove "below 2". There is a test for exactly that case.

Units come from a short, explicit list. µg/kg is converted to mg/kg by a factor of 0.001. Results in mg/l or µg/l are leachate or WAC tests from a different assessment, so they are excluded from the soil sheet. A unit the app does not recognise is blocked until a person confirms it.

5. Refusing to guess, as a rule in code

"Do not invent values" appears in the project's own error messages. It is enforced by one export gate, the same function the export, the review queue and the tests all use.

Determinand on the import sheet? Real sample label, not a placeholder? Confirmed or corrected by a person? Flagged for human entry (e.g. handwriting)? Value found as a token on the page? Both passes agree? Scanned page with low confidence? Export the value Excluded from the sheet Export the value Blocked: shown, not exported Waits in the review queue. A person confirms or types the value; it then passes the "confirmed" check. no no yes yes no no yes yes yes no no yes yes no
The export gate, in the order the code checks it. A value reaches the workbook only by passing every check, or by being confirmed by a person.

Handwriting gets its own rule. On a page image the app looks for saturated blue or red pixels, groups them into regions, and marks any result whose word box overlaps a pen mark as needing human entry. In the matrix that cell shows enter. The export is blocked until someone types the value. On the handwritten gold page, with pen over three cells, all 3 were refused. None was guessed. The test fails if any of them is exported as if it were printed.

The app also refuses to invent structure. It never creates a "Sample 1" column when it cannot find real sample IDs, and it drops labels that are not samples (report numbers, dates, a determinand name read as a header) from the exportable columns. When a full report has no certificate at all, the result is a clear message, not an empty grid that looks like "no contamination".

Testing and gold-cell evaluation

The accuracy claim on this page rests on gold cells. A gold cell is one fact read by a person directly from the source PDF: sample ID, determinand and the exact display string, including any <. Each gold file lists the cells for one document and its condition (clean text, scanned, rotated, handwritten). The scorer runs the real parse on the PDF and checks each gold cell. Correct means the app produced that sample and determinand with the same display string, and the result was not flagged for a person. Missing and wrong values are counted separately. Cells under pen marks are scored the other way round: correct only if the app refused to trust them.

Two rules keep the numbers honest. Gold is never generated from the app's own output. And clean and scanned results are never blended into one accuracy figure, because a text-layer extract and an OCR guess are not the same product.

Document (gold set)ConditionMethodGold cellsCorrect
i2 Analytical certificateClean text layerpdf.js word columns3636 (100%)
Chemtest certificate, table continues across a page breakClean text layerpdf.js word columns3434 (100%)
Chemtest pages 2 to 3 onlyClean text layerpdf.js word columns1515 (100%)
SOCOTEC certificateClean text layerpdf.js word columns3232 (100%)
Normec DETS certificateClean text layerpdf.js word columns3131 (100%)
Four-lab clean total148148 (100%)
Unbranded test certificate (synthetic)Clean text layergeneric fallback88 (100%)
i2 page, 150 dpi lossless rasterScanned (clean)Tesseract.js + preprocess220
Chemtest page, 2.2° skew, JPEG, speckleScanned (poor)Tesseract.js + preprocess200
i2 page rotated 90°Rotated scanTesseract.js orientation + preprocess220
SOCOTEC page, fax simulationScanned (poor)Tesseract.js + preprocess220
i2 page with blue ink over 3 cellsHandwrittendetect and flag3 ink cells3 of 3 refused, none guessed

Source: the project's degraded-document and benchmark evaluations, measured August and September 2026. The 105 scanned cells are the four scanned rows plus the 19 printed cells on the handwritten page.

We also ran a commercial table API on the same 156 clean cells, scoring only values it could ground on the page:

ExtractorCorrectWrongMissedCost for the run
Our pdf.js column clustering156 / 15600$0 (runs locally)
Reducto, grounded cells139 / 156143$1.53

So the local extractor stays primary on clean PDFs, and the API is kept for what it is better at: pages with no text layer. Azure, Textract and Google Document AI adapters exist but were not run, so we do not quote numbers for them.

156 / 156clean gold cells correct
3 / 3handwritten cells refused, none guessed
179automated test cases in 34 files
4lab formats with gold tests

Beyond the gold suite, the 179 Vitest cases cover value parsing (qualifiers, asbestos wording), unit blocking and conversion, screening thresholds, the export gate, grounding (a number not on the page must come back ungrounded), click-to-source highlighting, certificate location and appendix detection. Fifteen only run when the private report corpus or OCR language data is on the machine, because the client's files are never committed.

Results and status

  • In use. The tool was delivered to the practice, it is used on real jobs, and the client says it has worked well.
  • Accuracy on clean PDFs: 156 of 156 gold cells, with no wrong and no missed values, across i2, Chemtest, SOCOTEC, DETS and an unbranded certificate.
  • Real full reports: two real ground investigation reports carry 10 gold cells each, and both score 10 of 10. In a sweep of 10 real reports from the client's archive, from 6.8 MB to 122.9 MB, 8 produced samples and results. The other 2 stopped with a clear reason: one file that the PDF library could not open, and one with damaged compressed data where no certificate could be read. Neither produced a made-up table.
  • Honest limits: scanned certificates still need a cloud table service or a person. Only the first 48 certificate pages plus up to four further chunks are read in one pass on very large appendices, so a very long appendix may need a second pass.

The pattern behind this build, a gold set first, a second pass that must agree, and a gate that blocks anything unproven, is now how we approach all document intelligence work. For the domain detail see geotechnical report analysis, and for the general method how to extract AGS data from lab PDFs.

Questions about this project

Who was the SI Report Analyser built for?

A UK geoenvironmental practice that screens contamination results from site investigations. We do not name the client. The tool was built around their real lab reports, it is in use, and it has worked well for them.

Which laboratory formats does it read?

Certificates of Analysis from i2 Analytical, Chemtest, SOCOTEC and Normec DETS have their own hand-checked gold tests. A generic path reads unbranded results grids, and the tool can also find the lab certificates inside a full ground investigation report of several hundred pages.

How accurate is the extraction?

On clean, text-layer PDFs it reads 156 of 156 hand-checked cells correctly: 148 across the four lab formats and 8 on an unbranded test certificate. Scanned pages are quoted separately. The built-in OCR assigned 0 of 105 scanned gold cells correctly, which is why a scanned value never reaches the export without a person.

What happens with scanned or handwritten pages?

Scanned values are marked low confidence and blocked from export until someone confirms them. Coloured pen marks are detected on the page image, and any result underneath shows as enter, so a person types the real value. In the gold test all 3 handwritten cells were refused rather than guessed.

Why not use an off-the-shelf PDF table extractor or AI parser?

We measured them first. Line-based table tools found 4 cells on the borderless Chemtest certificate. A commercial table API scored 139 of 156 on the same clean gold cells, against 156 of 156 for our extractor. That API is still wired in as an optional salvage path for scanned pages.

Does the lab PDF leave the user's computer?

Digital certificates are read in the browser. The only exception is scanned certificate pages inside a full report: when a cloud table service is configured, those pages are sent as page images, not the PDF itself.

Can you build something similar for our documents?

Yes, if your documents feed decisions and you can share a sample of real files. We start by building a gold set from your documents, which tells us honestly what can be automated and what cannot.

Retyping numbers out of PDFs?

Send us four ugly examples. We will tell you honestly whether a gold set is achievable for your documents.

→ Book a strategy call

Estimate your build →