Expand description
Layout analysis and output rendering for pdfboss: turns pdfboss-text
spans into a structured layout IR, and the IR into a document.
Structs§
- BBox
- A device-space box:
ygrows upward, as in PDF user space. - Cell
- One table cell. An empty cell — or one covered by a neighbour’s span — carries no line.
- Extract
Report - What extraction could not read. Extraction is lenient the way rendering is — content that will not fetch, decode, or parse yields no text rather than an error — and this report is what keeps that leniency accountable: an empty result with an empty report really is an empty page.
- Font
Cache - Loaded fonts shared across page extractions of one document, keyed by the font dictionary’s object reference.
- Inline
- A run of same-styled text within a line.
textalready carries the spaces the word-gap rule inserted, so rendering a line is concatenation. - Line
- One visual line. The geometry travels with it because later structure passes — lists, tables, page headers and footers — classify lines by it.
- List
Item - One list item: its marker, the marker text’s length in characters (the continuation indent a wrapped item is measured against), and its lines.
- Markdown
- Markdown: ATX headings ranked by font size, one output line per source line, and emphasis around each run of styled text. Blocks — across pages too — are separated by a blank line.
- Page
Layout - One page’s blocks in reading order.
- Ruling
- An axis-aligned line segment a page draws, in the same y-up user space as
TextSpan: a table border, a separator, an underline. - Skipped
Text - One piece of content whose text (if any) is missing from the result.
- Text
- Plain text: every line of every block in reading order joined with
\n, pages separated by a form feed. Structure is invisible here — this is the adapter that must stay byte-equal to positional text extraction. - Text
Span - A positioned run of extracted text.
Enums§
- Block
- One structural unit of a page, in reading order.
- Marker
- What introduces a list item.
- Role
- What a paragraph is to the page: its body, or a page header or footer repeated on every page.
- Skip
Cause - Why the stream was skipped.
- Skipped
Text Kind - Which kind of operator stream was skipped.
Traits§
- Output
- Renders laid-out pages into one document.
Functions§
- document_
layout - Every page’s spans as structure, ranking heading sizes against the whole document, so one oversized page cannot redefine what body text is.
- document_
layout_ with_ rulings document_layoutwith each page’s rulings, so drawn grids become tables document-wide. With no rulings the two are the same function.- extract_
markdown - Extracts the whole document as Markdown: ATX headings, paragraphs, and
emphasis over the same positional layout
extract_textrenders flat. - extract_
markdown_ reporting extract_markdownwith oneExtractReportper page, in page order.- extract_
page_ markdown - One page as Markdown, ranking heading sizes against that page alone.
extract_markdownis the better answer whenever the document is at hand — a page whose text is all one size has no heading to find. - extract_
page_ markdown_ with extract_page_markdownagainst any object source. Signed likeextract_text_with, for the same reasons —ocgating included.- extract_
text - Extracts the page’s text with positional layout applied: spans grouped
into lines, lines ordered top to bottom and joined with
\n, spaces inserted at horizontal gaps. - extract_
text_ reporting extract_textwith the report of what could not be read: anExtractReportwhose entries name each skipped stream and why — unsupported filters (the passthrough image codecs included), undecodable bytes, unparseable content, missing resources, exhausted form limits. An empty text with an empty report really is an empty page.- extract_
text_ reporting_ cached extract_text_reportingwith fonts cached across pages: a caller walking a whole document —pdfboss_core::map_pagesincluded — passes oneFontCacheto every page and each font loads once for the document. The text is identical to the uncached call’s, page for page.- extract_
text_ reporting_ with extract_text_reportingagainst any object source. Signed likeextract_text_with, for the same reasons —ocgating included.- extract_
text_ with extract_textagainst any object source, awaiting whatever I/O the source needs to read the page — the same span extraction and layout.ocis the document’s optional-content visibility (the async document’soc_state());Noneextracts every layer.- layout
- Groups spans into lines (baselines within
0.5 · size), orders lines top to bottom and spans left to right, inserts a space at horizontal gaps wider thanWORD_GAPtimes the size, and joins lines with\n. A page with a clear two-column gutter reads column-major: full-width separators split it into bands, and within each band the left column flows before the right. - page_
layout - The page’s spans as structure, ranking heading sizes against this page
alone. Prefer
document_layoutwhenever the whole document is at hand: a page of nothing but large type has no body size of its own. - page_
layout_ with_ rulings page_layoutwith the page’s rulings: a lattice of drawn borders is read as a table ahead of lane occupancy. With no rulings the two are the same function.