trading_agent.attachments.pdf_text_reader
¶
Reads the text of a PDF, page by page, with pypdf.
A scanned PDF holds pictures of pages and no text, so it reads as empty; the store then tells the desk so, and the user can send the pages as pictures instead.
Typical usage example:
extracted = PdfTextReader().read(Path('annual_report.pdf'))
PdfTextReader
¶
Bases: TextReader
Reads a PDF's text layer.
read
¶
Reads every page's text, each under a page heading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The PDF. |
required |
Returns:
| Type | Description |
|---|---|
ExtractedText
|
The text and the number of pages. |
Raises:
| Type | Description |
|---|---|
TextReadError
|
The file is damaged, is not a PDF, or needs a password. |