Skip to content

PageText

A page’s extracted text: lines in reading order, and runs with their glyphs’ quads.

readonly glyphCount: number

The number of glyphs.

get buffers(): object

The arrays as the WASM returned them: quads (8 numbers per glyph), glyphText and glyphOffsets (glyph i is glyphText.slice(glyphOffsets[i], glyphOffsets[i + 1])). Post quads.buffer and glyphOffsets.buffer as transferables to move them to another thread; that detaches them here, and this PageText’s glyph() and glyphs() then throw (lines and runs keep working). They are this PageText’s own arrays, not copies: writing to them changes what glyph() returns.

object

readonly glyphOffsets: Uint32Array

readonly glyphText: string

readonly quads: Float32Array


get lines(): readonly string[]

The text by line (runs on one baseline joined, trimmed), in content order.

readonly string[]


get runs(): readonly PageTextRun[]

The runs, in content order (made on first use).

readonly PageTextRun[]


get unmapped(): number

Glyphs whose Unicode is unknown (shown as U+FFFD).

number

glyph(i): TextGlyph

Glyph i’s text and quad.

number

TextGlyph

RangeError for an index outside 0 … glyphCount - 1; TypeError once PageText.buffers’ arrays were transferred to another thread.


text(): string

The page’s text: its lines joined with \n.

string