pdf-inspector
pdf-inspector 架构:检测、版面、表格、Markdown 与 OCR
跟踪单次加载后的字体、内容流、布局和选择性 OCR。

你将学会
- Trace detection and layout stages
- Run native extraction and OCR safely
- Design provenance checks
开始前需要
- Basic Git and command-line usage
- Comfort reading a project README
You can explain the project, run its documented first step, and decide what to verify before adopting it.
先看结论
- Detection and extraction share one parsed document.
- Layout and tables are explicit intermediate stages.
- OCR is a governed side path with provenance.
Single-load pipeline
文档只加载一次,检测与提取共享状态;TextItem/PdfRect 经过列、行、表格和 Markdown 阶段,异常页进入独立 OCR 分支。
Use the pinned source evidence, record versions and assumptions, and ask a qualified reviewer to validate the result before adopting it.
Structure recovery
Column detection and line grouping feed heading, list, code, caption and table classifiers. Rectangle and alignment heuristics produce grids that the Markdown stage formats.
OCR as a side path
Broken encodings or image pages are flagged and routed selectively. The OCR envelope preserves pages, confidence, warnings and hosted-fallback recommendations without changing the native path.
Use the pinned source evidence, record versions and assumptions, and ask a qualified reviewer to validate the result before adopting it.
如何选择
| 比较维度 | 方案 A | 方案 B |
|---|---|---|
| Best when | You need predictable behavior and easy auditing | You need adaptive optimization and have reliable telemetry |
| Main risk | May leave performance on the table | Can become difficult to explain or debug |
实施步骤
- 1
Map bytes to detector and loader.
- 2
Trace text items through layout and tables.
- 3
Inspect Markdown post-processing.
- 4
Follow routed pages into OCR and warnings.
可复制示例
PDF bytes -> detector + single load
-> content streams/fonts/xobjects -> TextItems/PdfRects
-> layout -> tables -> Markdown
-> selected pages -> OCR envelope常见问题
Why parse a document once?
Shared state avoids redundant I/O and keeps detection, extraction, and provenance coherent.
How are tables detected?
The README describes rectangle-based and alignment-based heuristics feeding a grid formatter.
资料来源
- pdf-inspector README (captured 2026-08-31)来源核查 2026-08-31
- pdf-inspector repository来源核查 2026-08-31