ocr_to_markdown_file
Converts local PDF, DOCX, or image files to Markdown via OCR and saves the output to disk. Supports page range extraction, table formats, and optional image inclusion.
Instructions
OCR 本地文件并将生成的 Markdown 保存至磁盘。
默认使用 "mistral-ocr-latest" 模型。
默认不提取图片。若需提取,需设置 include_images=True。
非常适用于 PDF 或较长文档的 OCR,以避免因结果过大而超出模型上下文窗口限制。
可调参数:
- file_path (str): 必填,本地文档(如 PDF, PPTX, DOCX)或图片文件的绝对路径。
- pages (str, 默认 ""): 指定需要提取的页码范围(如 "0-3"),为空表示提取所有页面。
- output_dir (str, 默认 ""): 指定保存 Markdown 文件的目录路径,若为空则使用默认输出目录。
- table_format (str, 默认 "markdown"): 表格输出格式。可选 "markdown"、"html" 或 None。
- include_images (bool, 默认 False): 是否提取图片。若开启,将返回并保存图片信息。
- extract_header (bool, 默认 False): 是否专门解析并提取页眉。
- extract_footer (bool, 默认 False): 是否专门解析并提取页脚。
- use_cache (bool, 默认 True): 是否启用缓存,已处理过的内容直接返回缓存路径。
- image_limit (int, 默认 0): 限制单次提取的最大图片数量。
- image_min_size (int, 默认 0): 设置提取图片的最小尺寸限制(像素)。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pages | No | ||
| file_path | Yes | ||
| use_cache | No | ||
| output_dir | No | ||
| image_limit | No | ||
| table_format | No | markdown | |
| extract_footer | No | ||
| extract_header | No | ||
| image_min_size | No | ||
| include_images | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |