PdfReader
MMO\pdf · 1 symbole · générée le 30 Nov 2026
PdfReader
PdfReader.php:19Reads what a PDF says, as Markdown (toMarkdown): each page's text from poppler's pdftotext -layout, a page without text (a scan) read by tesseract from its image (pdftoppm), the document's metadata and form fields from
- Espace de noms
MMO\pdf- Étend
- aModule
- Voir
PDFTKabove them. Text laid out in columns (a quote's lines, a form's labels and values) stays as it is laid out, in a ``text block: a Markdown table would mix up a description going on below its line. Needs thepdftotextandpdftoppmbinaries (poppler-utils);tesseractfor scans andpdftk` for metadata are used when they are there.
Index
| COLUMN_GAP | Text laid out in columns: a gap of 3 spaces or more between two pieces of a line. | |
| minPageText | A page with fewer letters than that is taken for a scan. | |
| ocrDpi | The resolution a scanned page is read at. | |
| ocrLanguages | The languages Tesseract reads, its way ('fra+eng'). | |
| pdftoppm | poppler's pdftoppm: a scanned page as an image for $tesseract. | |
| pdftotext | poppler's pdftotext. | |
| tesseract | Tesseract, for the pages without text; '' to leave them unread. | |
| withInfo | Whether PDFTK's metadata and form fields go above the text. | |
| Fence($lines) static | Lines laid out in columns, as they are: their common indent removed, in a ```text block. | |
| Join($a, $b) static | Two lines of a paragraph, a word cut at the end of the first put back together. | |
| LayoutToMarkdown($text) static | Text laid out as on its page made Markdown: a paragraph's lines joined (a word cut at its end too), a bullet a list item, a short line in capitals alone a heading, and the lines laid out in columns… | |
| metadata($filename) | The metadata and form fields of the PDF (PDFTK::getInfo): title, author, dates, each field's value; nothing without pdftk, or when it can't read the file. | |
| ocr($filename, $page) | A page read by Tesseract from its image: through mmo.ocr's Tesseract::text() when it is loaded (and | |
| pages($filename, $ocr) | Each page's text, laid out as on the page; a scan's from Tesseract. | |
| Prose($lines) static | Lines of text: a heading, list items, or a paragraph. | |
| run($cmd) | Run a command: its output. | |
| toMarkdown($filename, $title, $ocr, $front) | The PDF as Markdown: a front matter (its pages, metadata and form fields), then each page after its <!-- page N --> (<!-- page N (ocr) --> for a scan read by Tesseract). |
Constantes1
COLUMN_GAP
Text laid out in columns: a gap of 3 spaces or more between two pieces of a line.
Propriétés7
minPageText
A page with fewer letters than that is taken for a scan.
- Type
- int
ocrDpi
The resolution a scanned page is read at.
- Type
- int
ocrLanguages
The languages Tesseract reads, its way ('fra+eng').
- Type
- string
pdftoppm
poppler's pdftoppm: a scanned page as an image for $tesseract.
- Type
- string
pdftotext
poppler's pdftotext.
- Type
- string
tesseract
Tesseract, for the pages without text; '' to leave them unread.
- Type
- string
withInfo
Whether PDFTK's metadata and form fields go above the text.
- Type
- bool
Méthodes9
Fence($lines)
staticPdfReader.php:188Lines laid out in columns, as they are: their common indent removed, in a ```text block.
Join($a, $b)
staticPdfReader.php:235Two lines of a paragraph, a word cut at the end of the first put back together.
LayoutToMarkdown($text)
staticPdfReader.php:162Text laid out as on its page made Markdown: a paragraph's lines joined (a word cut at its end too), a bullet a list item, a short line in capitals alone a heading, and the lines laid out in columns kept as they are, in a ```text block (blank lines between such blocks don't split them).
metadata($filename)
PdfReader.php:116The metadata and form fields of the PDF (PDFTK::getInfo): title, author, dates, each field's value; nothing without pdftk, or when it can't read the file.
ocr($filename, $page)
PdfReader.php:65A page read by Tesseract from its image: through mmo.ocr's Tesseract::text() when it is loaded (and
- Voir
$tesseractis the default), else by running$tesseracthere.
pages($filename, $ocr)
PdfReader.php:43Each page's text, laid out as on the page; a scan's from Tesseract.
| $filename | string | |
| $ocr = true | bool | read a page without text with Tesseract. |
| retourne | array | array{text: string, ocr: bool}> by page number, from 1. |
| lève | if the file doesn't exist. | |
| lève | if pdftotext can't read it (no PDF, protected...). |
Prose($lines)
staticPdfReader.php:199Lines of text: a heading, list items, or a paragraph.
run($cmd)
PdfReader.php:141Run a command: its output. @throws eRuntime when it fails.
toMarkdown($filename, $title, $ocr, $front)
PdfReader.php:94The PDF as Markdown: a front matter (its pages, metadata and form fields), then each page after its <!-- page N --> (<!-- page N (ocr) --> for a scan read by Tesseract).
| $filename | string | |
| $title = null | null | string | a # {title} above the text (the file's name...). |
| $ocr = true | bool | |
| $front = [] | array | |
| retourne | string |
Membres hérités (48)
| Constantes | Déclaré par | Description | |
|---|---|---|---|
ALERT | iLogLevel | Alert: Action must be taken immediately. | |
ALL | iLogLevel | Mask for all | |
ALL_PLUS | iLogLevel | debug everything | |
BACKTRACE | iLogLevel | ||
CRITICAL | iLogLevel | Critical: Critical conditions. | |
DEBUG | iLogLevel | Debug: Detailed debug information. | |
DEEP | iLogLevel | debug everything with arguments | |
EMERGENCY | iLogLevel | Emergency: System is unusable. | |
ERROR | iLogLevel | Error: Runtime errors that do not require immediate action but should typically be logged and monitored. | |
ERROR_PLUS | iLogLevel | Mask for all error | |
FATAL | iLogLevel | Mask for all fatal error | |
INFO | iLogLevel | Info: Interesting events. | |
INFO_PLUS | iLogLevel | Mask for all errors/warning/notices/info | |
MEMORY | iLogLevel | include backtrace object | |
NOTICE | iLogLevel | Notice: Normal but significant events. | |
NOTICE_PLUS | iLogLevel | Mask for all errors/warning/notices/info | |
TRACE | iLogLevel | include backtrace as origins | |
WARNING | iLogLevel | Warning: Exceptional occurrences that are not errors. | |
WARNING_PLUS | iLogLevel | Mask for all errors and warnings |
| Propriétés | Déclaré par | Description | |
|---|---|---|---|
verbosity | aModule |
| Méthodes | Déclaré par | Description | |
|---|---|---|---|
alert($message, $context) | aModule | Action must be taken immediately. | |
backtraces($message, $context) | aModule | Force-log a message at INFO level together with a full stack trace/memory snapshot (iLogLevel::BACKTRACE), bypassing the verbosity mask entirely (any non-zero verbosity is enough to trigger it). | |
Configure($config) | aModule | Merge $config into this module's configuration in the shared Configuration. | |
critical($message, $context) | aModule | Critical conditions. No-op if CRITICAL is currently filtered out by the verbosity mask. | |
debug($message, $context) | aModule | Detailed debug information. | |
debugName() | aModule | Human-readable identifier used as the default {origin} in this instance's log messages. | |
DefaultConfig() | aModule | The config a module starts from before anything loaded via Configuration is merged in. | |
emergency($message, $context) | aModule | System is unusable. No-op if EMERGENCY is currently filtered out by the verbosity mask. | |
error($message, $context) | aModule | Runtime errors that do not require immediate action but should typically be logged and monitored. | |
getVerbosity() | aModule | ||
info($message, $context) | aModule | Interesting events. No-op if INFO is currently filtered out by the verbosity mask. | |
Instantiate($config) | aModule | (Re)create the shared instance immediately, configured with $config merged into the class's existing config. | |
IsShared() | aModule | ||
log($level, $message, $context) | aModule | Logs with an arbitrary level. | |
notice($message, $context) | aModule | Normal but significant events. | |
offsetExists($key) | aModule | \ArrayAccess::offsetExists -- tells whether $key is a declared property at all, regardless of whether it is currently readable/writable through array access. | |
offsetGet($key) | aModule | \ArrayAccess::offsetGet -- reads a property directly, unless it has a #[Serialize(serialize: 'methodName')] attribute, in which case that zero-argument method is called instead (e.g. | |
offsetSet($key, $value) | aModule | \ArrayAccess::offsetSet -- sets a property directly, unless it has a #[Serialize(unserialize: 'methodName')] attribute, in which case that method is called with $value instead (e.g. | |
offsetUnset($key) | aModule | \ArrayAccess::offsetUnset -- equivalent to $module[$key] = null. | |
serialize($path, $serializer) | aModule | \MMO\core\interfaces\iSerializable::serialize -- exports every property (via | |
setVerbosity($verb) | aModule | Set the current verbosity mask, replacing whatever it was before. | |
Shared() | aModule | Get the shared instance, creating (and configuring) it on first call. | |
testVerbosity($level) | aModule | Test whether a given level (or set of levels) is currently enabled by this instance's verbosity mask. | |
traitUnshare($serialize) | aModule | Remove the shared instance, so the next Shared() call creates a fresh one. | |
unserialize($data, $path, $instances) | aModule | \MMO\core\interfaces\iSerializable::unserialize -- merges $data onto DefaultConfig, runs it through the (possibly overridden) constructor, then applies each resulting value to its property (via | |
Unshare($serialize) | aModule | Like tSingleton::Unshare, but also disconnects this module's instance from every event it was listening to (via Event::DisconnectListeners) before dropping it. | |
warning($message, $context) | aModule | Exceptional occurrences that are not errors. | |
__construct($config) | aModule | protected constructor, so it is not possible to do new Module(...) called by the serialization process just before being injected with data. |