PageText
A page’s extracted text: lines in reading order, and runs with their glyphs’ quads.
Properties
Section titled “Properties”glyphCount
Section titled “glyphCount”
readonlyglyphCount:number
The number of glyphs.
Accessors
Section titled “Accessors”buffers
Section titled “buffers”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”object
glyphOffsets
Section titled “glyphOffsets”
readonlyglyphOffsets:Uint32Array
glyphText
Section titled “glyphText”
readonlyglyphText:string
readonlyquads:Float32Array
Get Signature
Section titled “Get Signature”get lines(): readonly
string[]
The text by line (runs on one baseline joined, trimmed), in content order.
Returns
Section titled “Returns”readonly string[]
Get Signature
Section titled “Get Signature”get runs(): readonly
PageTextRun[]
The runs, in content order (made on first use).
Returns
Section titled “Returns”readonly PageTextRun[]
unmapped
Section titled “unmapped”Get Signature
Section titled “Get Signature”get unmapped():
number
Glyphs whose Unicode is unknown (shown as U+FFFD).
Returns
Section titled “Returns”number
Methods
Section titled “Methods”glyph()
Section titled “glyph()”glyph(
i):TextGlyph
Glyph i’s text and quad.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Throws
Section titled “Throws”RangeError for an index outside 0 … glyphCount - 1; TypeError once
PageText.buffers’ arrays were transferred to another thread.
text()
Section titled “text()”text():
string
The page’s text: its lines joined with \n.
Returns
Section titled “Returns”string