> ## Content Index
> Fetch the complete content index at: https://www.hubwiz.com/blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# ParseStudio：统一的文档提取API
- URL: https://www.hubwiz.com/blog/parsestudio-unified-api-layer-for-document-extraction/
- Published: 2024-12-05T02:09:45.000Z
- Updated: 2024-12-05T02:09:45.000Z
- Description: ParseStudio提供了一个统一的界面，支持多个解析后端，使文档解析一致、初学者友好且高效。无论你是处理 PDF、提取文本和图像还是分析表格，它都能确保你专注于目标，而不是工具。
- Author: admin
- Tags: LIBRARY, PARSESTUDIO, DOCLING, PYMUPDF, LLAMAPARSE, #Import 2026-10-14 14:41

> PDF 无处不在 — 发票、报告、研究论文、合同等等。然而，从这些文件中提取有意义的内容一直是​​一个挑战。

不同的工具专门用于提取特定内容 — 文本、表格、图像 — 但每个工具都有自己的学习曲线、语法和输出格式。这通常迫使开发人员和研究人员不得不同时使用多个库才能完成工作。

[ParseStudio ](https://github.com/chatclimate-ai/ParseStudio?ref=hubwiz.com)改变了这种说法。它提供了一个统一的界面，支持多个解析后端，使文档解析一致、初学者友好且高效。无论你是处理 PDF、提取文本和图像还是分析表格，它都能确保你专注于目标，而不是工具。

## 1、为什么选择 ParseStudio？

> 跨后端的统一语法

使用多个解析库时最大的挑战之一是学习它们的 API。每个后端都有自己的怪癖，这可能会减慢开发速度并导致代码难以维护。此软件包通过提供与后端交互的统一接口解决了此问题，例如：

- [Docling](https://github.com/DS4SD/docling?ref=hubwiz.com)：非常适合表格提取和 LLM 就绪解析文本。
- [PyMuPDF](https://pymupdf.readthedocs.io/?ref=hubwiz.com)：轻量级且高效。
- [LlamaParse](https://github.com/run-llama/llama%5Fparse?ref=hubwiz.com)：基于云和 AI 增强的提取。

允许通过更改单个参数在这些后端之间快速切换，而无需修改其余代码。

> 具有一致输出的多模式解析

[ParseStudio ](https://github.com/chatclimate-ai/ParseStudio?ref=hubwiz.com)支持使用相同语法从 PDF 中提取文本、表格和图像。无需为每种模式学习单独的 API — 一个库即可处理所有问题。

首先，通过 pip 安装：

```
pip install parsestudio
```

然后，使用提供的任何后端提取结构化输出。例如：

```
from parsestudio.parse import PDFParser

# Initialize the parser
parser = PDFParser(parser="docling") # pymupdf, llama

# Parse the PDF
output = parser.run(["path/to/file.pdf"], modalities=["text", "tables", "images"])[0]

# Access Text content (Markdown)
outputs.text  

# Access Table content
for table in outputs.tables:
    table.markdown  # Table in Markdown format
    table.dataframe # Table as Pandas Dataframe
    table.metadata  # Page number and Bounding Box

# Access Image content
for image in outputs.images:
    image.image.show()  # PIL image
    image.metadata      # Page number and Bounding Box
```

- 文本：干净的、LLM 就绪的文本，使用 Markdown 格式化。
- 表格：提取为 Markdown 和 Pandas DataFrames。
- 图像：随页码和边界框等元数据一起提供。
- 元数据：对于表格和图像元素，元数据包括页码和边界框。

> 设计上方便用户使用

为了试验 PDF 解析器而无需深入研究多个库文档，此软件包抽象了后端特定的复杂性。它允许你专注于提取内容，而不是排除语法故障。

即使是经验丰富的开发人员也能从简化的工作流程和缩短的设置时间中受益，使其成为任何使用 PDF 的人的省时解决方案。

## 2、ParseStudio支持的后端

ParseStudio目前支持3个后端：Docling、PyMuPDF和LlamaParse。

### 2.1 Docling

![](https://www.hubwiz.com/blog/content/images/2024/12/image-304.png)

[Docling](https://github.com/DS4SD/docling?ref=hubwiz.com) 是一个强大的后端，提供针对复杂文档量身定制的高级文档解析功能。

主要特点：

- 高级 PDF 理解：它理解详细的页面布局、阅读顺序和表格结构。
- 光学字符识别 (OCR)：对于扫描的 PDF 或包含文本的图像，Docling 集成了 OCR，可将文本图像转换为机器可读的文本。
- 使用 TableFormer 进行表格提取：Docling 使用 TableFormer 模型识别和重建文档中的表格结构。
- Markdown 中的图像嵌入：它允许将图像直接嵌入解析的 Markdown 输出中，保留原始文档的视觉上下文。

示例用法：

```
from parsestudio.parse import PDFParser
from docling.datamodel.pipeline_options import PdfPipelineOptions, TableStructureOptions, EasyOcrOptions, TableFormerMode
from docling.backend.docling_parse_backend import DoclingParseDocumentBackend

# Optional
# Set pipeline options to customize the extraction. Defaults:
pipeline_options = PdfPipelineOptions(
  do_ocr=True, 
  do_table_structure=True, 
  table_structure_options=TableStructureOptions(
      do_cell_matching=False, 
      mode=TableFormerMode.ACCURATE
      ), 
  ocr_options=EasyOcrOptions(
      force_full_page_ocr=True, 
      use_gpu=False
      ), 
  images_scale=1.0, 
  generate_picture_images=True
)

# Set Docling backend. Default:
backend = DoclingParseDocumentBackend

parser = PDFParser(parser="docling", parser_kwargs={"pipeline_options": pipeline_options, "backend": backend})
```

何时使用 Docling：

- 处理需要详细布局分析的复杂文档时。
- 对于包含扫描图像或以未知字体编码的文本的文档，OCR 是必需的。
- 当精确的表格提取对于数据分析至关重要时。

### 2.2 PyMuPDF

![](https://www.hubwiz.com/blog/content/images/2024/12/image-305.png)

[PyMuPDF](https://github.com/pymupdf/PyMuPDF?ref=hubwiz.com) 是一种轻量级且高效的后端，非常适合优先考虑速度和简单性的任务。它基于 MuPDF 引擎构建，非常适合解析具有最小依赖性的 PDF。

主要特点：

- 高性能：针对速度进行了优化，适合处理大量 PDF。
- 最小依赖性：需要最少的安装，确保快速设置和低资源使用率。

示例用法：

```
from parsestudio.parse import PDFParser

parser = PDFParser(parser="pymupdf")
```

最佳用例：

- 快速提取。
- 需要轻量级解析器和最少设置的场景。

### 2.3 LlamaParser

![](https://www.hubwiz.com/blog/content/images/2024/12/image-306.png)

[LlamaParse ](https://bap-software.net/en/knowledge/llamaindex-and-how-it-works/?ref=hubwiz.com)是一个 AI 增强型后端，旨在处理非结构化的复杂布局和非标准内容。

主要特点：

- AI 驱动的解析：利用 AI 模型提高从布局复杂的文档中提取内容的准确性。
- API 驱动的工作流程：基于云的解决方案，适用于大型或复杂的文档，不会给本地资源带来压力。需要 API 密钥。

设置说明：

- 在项目的根目录中创建一个 `.env` 文件。
- 添加你的 Llama Index API 密钥： `LLAMA_PARSE_KEY=your-api-key`

示例用法：

```
from parsestudio.parse import PDFParser

# Set options to customize extracion. Defaults:
llama_options = {
  'show_progress': True,
  'ignore_errors': False, 
  'split_by_page': False, 
  'invalidate_cache': False, 
  'do_not_cache': False, 
  'result_type': 'markdown', 
  'continuous_mode': True, 
  'take_screenshot': True, 
  'disable_ocr': False, 
  'is_formatting_instruction': False, 
  'premium_mode': True, 
  'verbose': False
}

parser = PDFParser(parser="llama", llama_options)
```

‌ 最佳用例：

- 解析具有复杂布局的非结构化文档。
- 需要基于云的 AI 实现可扩展性的应用程序。

## 3、结束语

ParseStudio 是一个统一的解决方案，可简化文档处理、支持多模式解析并在不同后端提供一致的输出。凭借不断增长的功能集和 Llama Parse 等基于云的功能，它是希望简化工作流程的开发人员、研究人员和企业的完美选择。

准备好释放文档的全部潜力了吗？今天就试试吧！

---

原文链接：[ParseStudio: Simplifying Document Parsing with Unified Syntax](https://medium.com/@imene.kolli%5F74575/parsestudio-simplifying-document-parsing-with-unified-syntax-5c5a3d3478d5?ref=hubwiz.com)

汇智网翻译整理，转载请标明出处