page library

PAGE XML OCR document import: parsing, reading order, and binding onto canonical text snapshots.

PAGE is a sidecar format for OCR results over scanned pages, published by PRImA. Unseal parses the supported subset — the 2019-07-15 namespace: metadata, page identity and dimensions, all fifteen region kinds, text lines and words, native polygons and baselines, the reading order, and TextEquiv alternatives with confidence and language — into a PageXmlDocument, and bindPageToSnapshot maps its text onto the UTF-16 ranges of a host-provided canonical text snapshot, preserving OCR origin and confidence. Native polygons stay on the document; bounding boxes are the explicitly derived projection. Unseal does not run OCR.

Classes

PageXmlAmbiguousWord
One ambiguous mapped unit: its place in the imported document and the bounded candidate ranges the target text offers. Distinct OCR readings can make a unit ambiguous even with one target candidate.
PageXmlBaseline
A Baseline polyline: the stored points and its confidence when declared.
PageXmlBindLimits
Work bounds of one PAGE-to-snapshot binding. The projection scan is linear in the target text per searched unit; the budget keeps a hostile document from quadratic work and reports the refusal typed.
PageXmlBoundSpatialText
The transport view of a binding: pages, outcome counts, ambiguities, provenance, and the target identity tuple — everything a host needs to persist or re-verify the binding without keeping the target text or the parsed document resident. The worker op returns this view; wire codecs encode it as structured-clone-safe maps.
PageXmlDocument
A parsed PAGE XML document: the sidecar's metadata and its page with positioned content.
PageXmlGroup
A nested reading order group, ordered or unordered.
PageXmlOrderNode
One node inside a reading order group tree: a region reference or a nested group. The parse variant decides whether an index is required (the indexed group styles) or forbidden (the unordered styles); the model carries it as nullable either way.
PageXmlPage
One PAGE page: declared image identity and dimensions, orientation and confidence figures, its regions in stored order, and the optional reading order.
PageXmlPolygon
A native PAGE polygon: the stored integer point list and the geometry confidence when the sidecar declares one.
PageXmlReadingOrder
A page's ReadingOrder: the root group tree with validated, deterministic sequencing.
PageXmlRegion
One region of any kind, with its native polygon. Text regions carry their lines, language and reading-order attributes; the other kinds stay geometry-only.
PageXmlRegionRef
A reference to one region by id.
PageXmlSnapshotBinding
The result of binding a PAGE document onto one canonical snapshot: the spatial page whose zones address the target text's UTF-16 ranges, with the import's provenance and the full mapping outcome.
PageXmlTextContent
The ordered TextEquiv set of one region, line, or word, with the declared deterministic choice: the first alternative in document order among those with the lowest index; alternatives without an index sort after every indexed one at equal rank.
PageXmlTextEquiv
One TextEquiv alternative: the Unicode text the schema requires, the optional plain-text variant, the declared order index, and the declared confidence.
PageXmlTextLine
One TextLine: native polygon, optional baseline, language, and its words in stored order.
PageXmlWord
One Word: native polygon, language, and its text content.
PageXmlWordPlace
Where a mapped unit sits in the parsed document. Line and word indexes are null for line- and region-level mappings — the granularity levels the sidecar itself declares.
SpatialRect
A rectangle in the canonical top-left page space: the x and y fields place the upper-left corner, sizes grow right and down.
SpatialTextPage
One page of positioned text: the shared shape DjVu hidden text and imported ALTO both project onto.
SpatialTextProvenance
The provenance of a spatial text page: its origin, the OCR software when the source names one, and whether the source declared confidence values at all.
SpatialTextZone
One positioned text zone: a hierarchy kind, a rectangle in the page's canonical top-left space, and the UTF-16 code-unit range it selects in the page's canonical text.
SpatialZoneLookup
Range queries over one SpatialTextPage's zones: which zone holds a text offset, which zones overlap a text range, which region a zone belongs to.

Enums

PageXmlRegionKind
The fifteen region kinds the PAGE 2019 schema defines.
SpatialTextOrigin
Where a spatial text page's zones came from.
SpatialUnit
The unit every coordinate of one spatial document is expressed in.
SpatialZoneKind
The hierarchy levels DjVu hidden text and ALTO share.

Constants

pageXmlNamespace → const String
The one namespace the subset supports: PAGE content 2019-07-15.

Functions

bindPageToSnapshot({required PageXmlDocument document, required CanonicalTextSnapshot target, PageXmlBindLimits limits = const PageXmlBindLimits()}) → PageXmlSnapshotBinding
Binds document's positioned text onto target's canonical text: each word, line or region maps to the UTF-16 range its chosen TextEquiv selects in the target, parents aggregate their children's ranges, and every outcome stays observable.
parsePageXmlDocument(Uint8List bytes) → PageXmlDocument
Parses PAGE XML bytes into a PageXmlDocument under the declared 2019-07-15 subset: metadata, page identity and dimensions, all region kinds, native polygons and baselines, the ReadingOrder tree, and TextEquiv alternatives with confidence and language.
requirePageXml(bool condition, String message) → void
Throws a PageXmlException when condition does not hold; the parser's shared guard.

Exceptions / Errors

PageXmlException
Malformed, excessive, or inconsistent PAGE XML input.
PageXmlUnsupportedFeatureException
A structurally well-formed PAGE document whose namespace version or declared feature set sits outside the supported 2019-07-15 subset.