1. Background
A similarity checker does not compare the pixels of a rendered PDF page. It compares a character sequence derived from that page, then applies tokenisation and matching rules. PDF is designed to reproduce a page's visual appearance. Its content stream can place text fragments at coordinates in an order that supports painting the page, rather than an order a reader would follow. PDF can also contain optional logical structure for tagged documents. 3 4
A born-digital PDF usually originates in a word processor, typesetter, browser, or design application. It may contain text-showing instructions, font data, and mappings that allow software to recover characters. That process is text extraction.
A scanned PDF begins as page images. It has no encoded text unless an OCR process adds a text layer. OCR estimates characters from pixels, which introduces a different uncertainty from reading encoded PDF text. Tesseract is an OCR engine for document-image analysis. 5
Many documents use both paths. A report might have an exported cover page, scanned appendices, and an OCR layer added later. Intake should therefore classify pages instead of assigning one extraction method to a whole file.
2. Method
Treat extraction as a reproducible transformation, not an invisible preparation step. Let be a PDF, an extraction configuration, and a declared normalisation procedure. The derived string is:
When two configurations produce different strings, a simple diagnostic is sequence distance:
Here, is the longest common subsequence. This quantity measures extraction drift. It is not a plagiarism score or an AI-likelihood estimate. A larger value says that two outputs differ in order or content. It does not establish which output is closer to the author's intended prose.
2.1 Encoded text is not simply stored as words
In a PDF content stream, character codes select glyphs from a font. A glyph is a drawn shape, not necessarily a Unicode character. Recovering text can depend on a ToUnicode CMap supplied by the PDF. The PDF specification defines these mappings because glyph selection alone is insufficient for meaningful text recovery. 3
This explains a familiar failure: a page displays cleanly, but copied text is wrong. An embedded font can give a viewer enough information to draw letters while an absent or unusual Unicode mapping leaves extraction ambiguous. Strange extracted output is therefore a reason to inspect the source page, not a reason to infer anything about the writer.
2.2 Reading order is inferred
A PDF can place a title, two columns, a footnote, and page furniture at arbitrary positions. An extractor may use content-stream order, page geometry, tagged structure, or a combination. Each choice can change the sequence passed to a similarity matcher.
Apache PDFBox exposes one such choice. Its ExtractText command documents -sort, which sorts text before writing output. 1 Sorting can improve output for a simple layout, but it does not define reading order for every page. A two-column article may require the left column followed by the right. A sidebar may belong after one paragraph, not after an entire column.
| Page feature | Plausible extraction outcome | Review action |
|---|---|---|
| Two columns | Lines alternate between columns | Check the complete span on the rendered page |
| Header and footer | Repeated furniture joins body prose | Remove it only under a recorded rule |
| Footnote | A note interrupts a sentence | Preserve page and location evidence |
| Positioned labels | Labels follow paint order | Inspect nearby coordinates and tags |
Table 1. Illustrative outcomes, not measured error rates. PDF content streams and optional logical structure are described in the PDF standards. 3 4
3. Results
The synthetic transformations below show how one visible page can produce different candidate matches.
3.1 Columns and fragments
An illustrative page might visibly read as two columns:
Visible reading order: A1 A2 A3 | B1 B2 B3
Possible output: A1 B1 A2 B2 A3 B3
The second sequence does not prove that the PDF is defective. It shows that layout reconstruction occurred. Interleaving can split a long phrase, reducing an exact-match candidate. It can also join nearby words from separate columns, creating a candidate phrase that was not present in the prose. A reviewer needs the source page and passage locations, not only an extracted snippet.
3.2 Ligatures and mappings
A ligature is one displayed glyph that can represent multiple letters. Unicode assigns U+FB00 to LATIN SMALL LIGATURE FF. 2 Depending on font mapping and normalisation, visible text may be extracted as ordinary letters, as a ligature character, or as a replacement character when mapping information is unavailable.
Compatibility normalisation can make some forms comparable, but it should be recorded. It can also change distinctions such as superscripts and special symbols. A conservative pipeline retains raw extraction and creates a separate documented normalised representation for candidate retrieval.
3.3 Line-end hyphenation
A line break and hyphen drawn at a right margin can survive extraction:
The method is reproduc-
ible across repeated runs.
Possible output includes repro- ducible, reproducible, or a line-break-preserving form. Removing every hyphen is unsafe because compounds such as evidence-based carry meaning. A narrower rule may join a hyphen plus line break when surrounding fragments are alphabetic, while retaining raw text and marking the edit. Names, chemical terms, and deliberate line-break styling still need review.
3.4 OCR is a separate branch
For an image-only page, direct extraction returns little or no usable text. OCR may make the page searchable, but the result is estimated from pixels. Skew, faint ink, page curvature, tables, and low resolution can affect characters and word boundaries. 5 An audit trail should not silently mix OCR output with born-digital extraction. It should identify the page path and treat exact character-level conclusions with more caution when text was recognised rather than encoded.
4. Interpretation
The useful question is not, “Did this PDF contain text?” It is, “Which string was derived, by which path, with which settings?” That record makes a missing candidate or surprising candidate explainable.
A practical pipeline separates four stages:
- Preserve the original PDF and its page count.
- Extract encoded text page by page. Route image-only or unusable pages to a labelled OCR branch.
- Store raw output before applying rules for layout, ligatures, whitespace, or hyphenation.
- Compare a normalised representation for retrieval, then present candidate similarity evidence beside the rendered source pages.
Similarity is evidence for a human to interpret. Extraction errors, shared terminology, quotations, references, and disrupted reading order can all affect it. AI-likelihood signals likewise require careful handling: they are calibrated estimates, not verdicts about authorship.
5. Limitations
This note describes documented mechanisms. It does not measure PDF error rates in the wild or establish that one extractor is better than another. Outcomes depend on the PDF producer, font mappings, tagging, language, layout, and extraction configuration.
The examples are small. They do not represent tables, forms, mathematical notation, right-to-left scripts, or heavily designed pages. Tagged PDF may provide useful structure, but tag quality cannot be assumed. Geometry sorting may help a plain page while damaging a complex one. OCR quality also depends on the scan.
The cautious practice is to preserve provenance, expose the extraction path, and compare important evidence with the page that produced it. For product context, see Silvertext features or return to the blog.
References
- 1. Apache Software Foundation. 2018. Apache PDFBox 2.0.13 Documentation: ExtractText Command Line Application. Apache PDFBox. https://pdfbox.apache.org/2.0/commandline.html#extracttext https://pdfbox.apache.org/2.0/commandline.html#extracttext
- 2. The Unicode Consortium. 2023. Unicode 15.1 Character Code Charts: Alphabetic Presentation Forms. Unicode, Inc. https://www.unicode.org/charts/PDF/UFB00.pdf https://www.unicode.org/charts/PDF/UFB00.pdf
- 3. Adobe Systems Incorporated. 2006. PDF Reference, Sixth Edition: Adobe Portable Document Format Version 1.7. Adobe Systems Incorporated. https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf
- 4. International Organization for Standardization. 2020. ISO 32000-2:2020, Document management: Portable document format, Part 2: PDF 2.0. ISO. https://committee.iso.org/cms/live/live/en/sites/isoorg/contents/data/standard/07/58/75839.html?browse=ics https://committee.iso.org/cms/live/live/en/sites/isoorg/contents/data/standard/07/58/75839.html?browse=ics
- 5. Ray Smith. 2007. An Overview of the Tesseract OCR Engine. Proceedings of the Ninth International Conference on Document Analysis and Recognition, IEEE Computer Society. https://research.google/pubs/an-overview-of-the-tesseract-ocr-engine/ https://research.google/pubs/an-overview-of-the-tesseract-ocr-engine/



