pdf-inspector 3 步上手:Rust 本地 PDF 类型识别与 Markdown 提取指南
【免费下载链接】pdf-inspectorFast Rust library for PDF inspection, classification, and text extraction. Intelligently detects scanned vs text-based PDFs to enable smart routing decisions.项目地址: https://gitcode.com/GitHub_Trending/pdf/pdf-inspector
你手里有一批 PDF,不知道哪些能直接抽文字、哪些必须走 OCR?pdf-inspector 用纯 Rust 在本地完成 PDF 类型识别与 Markdown 提取:文本型文档 200ms 内出结果,逐页给出置信度,帮你决定哪页送去 OCR、哪页直接本地处理。
⚡ 能力速览:三个数字定去留
- 完整处理(检测 + 提取 + 转 Markdown):文本型 PDF 本地耗时 < 200ms
- 类型识别仅需 10–50ms;在 200 份文档的基准上综合得分 0.875,表格 TEDS 0.814
- 一套 Rust 内核,提供 Python / Node.js / WebAssembly 三种绑定
🚀 三步跑通第一个 PDF 类型识别与提取
Step 1 · 装好它。终端执行pip install pdf-inspector,预编译 wheel 覆盖 Linux、macOS、Windows;Node.js 与 Wasm 绑定则分别用 npm 安装,细节见各自 README。
Step 2 · 最小调用。整个流程就一行核心 API:
import pdf_inspector result = pdf_inspector.process_pdf("document.pdf") print(result.pdf_type) # text_based / scanned / image_based / mixed print(result.markdown) # Markdown 字符串或 NoneStep 3 · 看懂输出。pdf_type告诉你这份 PDF 属于哪一类;confidence是 0–1 的置信度;markdown是转换后的正文,提取失败时为 None;pages_needing_ocr列出需要走 OCR 的页码,方便你只对这些页做重处理。
🔧 换个姿势用
- 如果你只是想快速判断类型、不抽内容:调用
detect_pdf(),十几毫秒返回类型、置信度和需 OCR 页码。 - 如果你要精确到坐标的文本(做高亮、批注、引用):
extract_text_with_positions()给出每个文本项的 X/Y、字号与字体名;只想看某几页时,用process_pdf()的pages参数切片。
想深入 API 细节和基准方法论,直接翻官方文档: → Python 完整 API → 性能基准测试 → Node.js 绑定参考
【免费下载链接】pdf-inspectorFast Rust library for PDF inspection, classification, and text extraction. Intelligently detects scanned vs text-based PDFs to enable smart routing decisions.项目地址: https://gitcode.com/GitHub_Trending/pdf/pdf-inspector
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考