PDF Reader

Parameters and methods of PDFReader, which reads PDF files into documents.

PDFReader reads data from PDF files.

Parameters

ParameterTypeDefaultDescription
split_on_pagesboolTrueCreate one document per page instead of one document for the whole file
page_start_numbering_formatOptional[str]"<start page {page_nr}>"Marker inserted at the start of each page when PDFReader detects a consistent printed page-number sequence. Set to an empty string to remove
page_end_numbering_formatOptional[str]"<end page {page_nr}>"Marker inserted at the end of each page when PDFReader detects a consistent printed page-number sequence. Set to an empty string to remove
passwordOptional[str]NonePassword to unlock encrypted PDFs
sanitize_contentboolTrueJoin fragmented lines from PDF text extraction into flowing text. Disable to preserve whitespace-sensitive content like code blocks or tables
chunking_strategyOptional[ChunkingStrategy]DocumentChunking()Strategy used to chunk documents

PDFReader also accepts the base Reader constructor parameters.

Methods

read()

Reads a PDF and returns a list of documents.

ParameterTypeDefaultDescription
pdfOptional[Union[str, Path, IO[Any]]]NonePath to the PDF file or a file-like object
nameOptional[str]NoneName override for the resulting documents
passwordOptional[str]NonePassword to unlock the PDF. Falls back to the constructor password when not set

async_read()

The async variant of read(). It accepts the same parameters.