PyMuPDF4LLMLoader document loader. For detailed documentation of all PyMuPDF4LLMLoader features and configurations head to the GitHub repository.
概述
集成详情
加载器特性
设置
To access PyMuPDF4LLM document loader you’ll need to install thelangchain-pymupdf4llm integration package.
凭证
No credentials are required to use PyMuPDF4LLMLoader. 要启用模型调用的自动追踪,请设置你的 LangSmith API 密钥:安装
安装 langchain-community and langchain-pymupdf4llm。初始化
现在我们可以实例化模型对象并加载文档:加载
惰性加载
- source
- page (if in mode page)
- total_page
- creationdate
- creator
- producer
Splitting mode & custom pages delimiter
加载 PDF 文件时,你可以用两种不同的方式分割它:- By page
- As a single text flow
Extract the PDF by page. each page is extracted as a langchain document object
page (page number). But in some cases we could want to process the pdf as a single text flow (so we don’t cut some paragraphs in half). In this case you can use the single mode :
Extract the whole PDF as a single langchain document object
page (page_number) metadata disappears. Here’s how to clearly identify where pages end in the text flow :
Add a custom pages_delimiter to identify where are ends of pages in single mode
pages_delimiter is \n-----\n\n.
This could simply be \n, or \f to clearly indicate a page change, or <!— PAGE BREAK —> for seamless injection in a Markdown viewer without a visual effect.
Extract images from the PDF
You can extract images from your PDFs (in text form) with a choice of three different solutions:- rapidOCR (lightweight Optical Character Recognition tool)
- Tesseract (OCR tool with high precision)
- Multimodal language model
Extract images from the PDF with rapidOCR
Extract images from the PDF with tesseract
Extract images from the PDF with multimodal model
Extract tables from the PDF
With PyMUPDF4LLM you can extract tables from your PDFs in markdown format :Working with files
许多文档加载器涉及文件解析。这类加载器之间的差异通常在于文件的解析方式,而不是文件的加载方式。 For example, you can useopen to read the binary content of either a PDF or a markdown file, but you need different parsing logic to convert that binary data into text.
As a result, it can be helpful to decouple the parsing logic from the loading logic, which makes it easier to reuse a given parser regardless of how the data was loaded.
你可以使用此策略用相同的解析参数分析不同的文件。
API 参考
For detailed documentation of allPyMuPDF4LLMLoader features and configurations head to the GitHub repository: github.com/lakinduboteju/langchain-pymupdf4llm
通过 MCP 将这些文档连接到 Claude、VSCode 等工具以获取实时答案。

