Types
The shape of everything that crosses the boundary. Hand-written, with no any.
Document and page
TypeScript
interface DocumentInfo { pageCount: number documentKind: 'born-digital' | 'scanned' | 'mixed' taggedStatus: 'tagged' | 'untagged' | 'degraded' hasXfa: boolean encrypted: boolean revisionCount: number memoryUsage: number permissions: Permissions leniencies: Leniency[]}
interface Page { index: number mediaBox: Rect rotate: number scanned: boolean paragraphs: Paragraph[] blocks: Block[] images: ImageBlock[] tables: TableBlock[]}
interface Paragraph { id: number text: string box: Rect lineCount: number leading: number alignment: 'left' | 'right' | 'centre' | 'justified' textConfidence: 'exact' | 'partial' | 'none'}
interface Rect { x0: number; y0: number; x1: number; y1: number }Outcomes
TypeScript
type Fidelity = 'exact' | 'reembedded' | 'substituted' | 'overlaid'
interface Outcome { fidelity: Fidelity /** Anything that had to give: kerning dropped, a box grown, a line re-broken. */ compromises: string[]}
interface Saved { bytes: Uint8Array mode: 'incremental' | 'full-rewrite' /** Zero for a full rewrite, where the concept does not apply. */ bytesAppended: number warnings: Warning[]}
interface Leniency { kind: string offset: number detail: string}Composition
TypeScript
type Content = | { kind: 'heading'; level: 1 | 2 | 3 | 4 | 5 | 6; text: string } | { kind: 'paragraph'; text: string } | { kind: 'list'; items: readonly string[] }
interface CreateOptions { pageSize?: 'letter' | 'a4' margin?: number columns?: number gutter?: number bodySize?: number headingSizes?: readonly number[] title?: string}
interface Composition { pages: number lines: number /** Blocks drawn as plain text because their structure is not drawn. */ approximated: number /** Characters the typeface has no glyph for. Dropped, not substituted. */ missing: string[] baseFont: string composite: boolean /** /StemV cannot be measured from a TrueType file. Always true today. */ stemVEstimated: boolean}Why hand-written
Generated declarations from wasm-bindgen describe the ABI rather than the API, and
any turns up in exactly the places a caller most needs a type. These are written by hand and checked by compiling a file of deliberate mistakes on every build.