| Name | Type | Description |
|---|---|---|
password | Optional[str] | Default: NoneOptional password for opening encrypted PDFs. |
mode | Literal['single', 'page'] | Default: 'single'Extraction mode to use. Either "single" or "page" for page-wise extraction. |
pages_delimiter | str | Default: _DEFAULT_PAGES_DELIMITER |
extract_images | bool | Default: False |
images_inner_format | Literal['text', 'markdown-img', 'html-img'] | Default: 'text' |
concatenate_pages | Optional[bool] | Default: None |
Parse a blob from a PDF using pdfminer.six library.
This class provides methods to parse a blob from a PDF document, supporting various configurations such as handling password-protected PDFs, extracting images, and defining extraction mode. It integrates the 'pdfminer.six' library for PDF processing and offers synchronous blob parsing.
Examples: Setup:
.. code-block:: bash
pip install -U langchain-community pdfminer.six pillow
Load a blob from a PDF file:
.. code-block:: python
from langchain_core.documents.base import Blob
blob = Blob.from_path("./example_data/layout-parser-paper.pdf")
Instantiate the parser:
.. code-block:: python
from langchain_community.document_loaders.parsers import PDFMinerParser
parser = PDFMinerParser(
# password = None,
mode = "single",
pages_delimiter = "
", # extract_images = True, # images_to_text = convert_images_to_text_with_tesseract(), )
Lazily parse the blob:
.. code-block:: python
docs = []
docs_lazy = parser.lazy_parse(blob)
for doc in docs_lazy:
docs.append(doc)
print(docs[0].page_content[:100])
print(docs[0].metadata)
A string delimiter to separate pages in single-mode extraction.
Whether to extract images from PDF.
The format for the parsed output.
![body)(#)]alt text of an tag and link to
(<img alt="{body}" src="#"/>)Deprecated. If True, concatenate all PDF pages into one a single document. Otherwise, return one document per page.