How pages are read
Which reader handles each kind of page, and what a unit tells you about how it was read.
Last updated
By file type
| File | How it is read |
|---|---|
Each page is rendered and read from its image. The reading is placed against the page's own text layer and drawing where the page has them. The method is ocr. | |
| JPEG, PNG | Read as a one-page document, the same way as a PDF page. The method is ocr. |
| XLSX, XLS, CSV and other spreadsheets | Cells are read from the workbook. No model is involved. The method is spreadsheet_cells. |
| DOCX, PPTX, HTML, text | The file's own text is read directly. The method is text_layer. |
The method is reported in extraction_method. The top-level value is the method behind most of the document, and each unit carries its own.
Page types
Before a PDF or image page is read, it is given a page type from its text layer and its drawing. In standard mode the type decides how the page is read. In lite mode every type is read the same way.
reader.page_type | The page is |
|---|---|
plain_text | Running text in one column. |
complex_text | Text in several columns, with rotated lines, in a non-Latin script, or with a damaged text layer. |
table | A ruled table or a grid of aligned numbers. |
dense | A table with very many cells. |
chart | Charts drawn as bars, areas or lines. |
form | A form with fields, check boxes or fill-in lines. |
scan | An image of a page with little or no text layer. |
reader.page_type is the kind of page the reading was made for. The reader behind each page type changes as readers improve, so store reader with your results.
Elements and boxes
A page with layout carries elements in reading order. The types are title, section_header, text, list_item, list, table, picture, caption, footnote, formula, page_header and page_footer.
Each element has its transcription in markdown. Tables are HTML or Markdown tables. A picture keeps its readable lettering and any chart data table in markdown, and a description of what it shows in description.
bbox is [x0, y0, x1, y1] in the normalized-top-left-v1 coordinate system: fractions of the page from 0 to 1, origin at the top left. geometry gives the page width, height and rotation.
x0, y0, x1, y1 = element["bbox"]
left, top = x0 * unit["geometry"]["width"], y0 * unit["geometry"]["height"]
right, bottom = x1 * unit["geometry"]["width"], y1 * unit["geometry"]["height"]When a page cannot be read cleanly
If the first reader fails on a page, a second reader takes over. In lite mode the page is retried instead. If no visual reading completes, the page falls back to its text layer or to plain OCR. Such a unit has no reader, carries state and a reason, and is listed in lost. The document is then partial with complete: false.
reason is diagnostic text such as ocr_transcription_unreviewed or visual_extraction_incomplete. Branch on the document code, which is stable, and show reason to a person. Text that comes from the service that read a page, such as its name or its own error wording, is never passed on. In reason, error and message it is replaced with the document could not be read for the document, or the page could not be read for a page or a lost entry, and the code before the colon is kept, as in extraction_failed:the document could not be read.