Ream
Defined in: src/core/converter/ream.ts:122
The object face of the library: parse a document once into the format-neutral FlowDoc interlayer, then convert it to any number of targets without re-reading the source.
const doc = Ream.parse(bytes); // sniff → reader → FlowDocconst pdf = await doc.convert('pdf', { fonts });const svg = await doc.convert('svg', { fonts });It is a thin GRASP Controller: readers parse, flowRenderOptions projects the
FlowDoc, and layout/emit plus the writers do the work. As a deliberate
composition root, importing it pulls in every format module — prefer the
per-format functions when bundle size matters more than convenience. The
source bytes are retained only for the two source-touching features: docx
substitute-font auto-detection and PDF/A-3 embedSource.
Properties
Section titled “Properties”
readonlyflow:FlowDoc
Defined in: src/core/converter/ream.ts:133
The interlayer — the parsed, format-neutral document tree.
losses
Section titled “losses”
readonlylosses: readonlyLoss[]
Defined in: src/core/converter/ream.ts:135
Losses recorded while reading the source.
readonlysheet:SheetDoc|undefined
Defined in: src/core/converter/ream.ts:134
The native SpreadsheetML tree when the source is a spreadsheet (xlsx); Ream.flow is its projection through the print model.
Accessors
Section titled “Accessors”format
Section titled “format”Get Signature
Section titled “Get Signature”get format():
string
Defined in: src/core/converter/ream.ts:165
The source format id ('docx', 'xlsx', …).
Returns
Section titled “Returns”string
Methods
Section titled “Methods”convert()
Section titled “convert()”convert(
to,options?):Promise<Uint8Array<ArrayBufferLike>>
Defined in: src/core/converter/ream.ts:177
Convert the parsed document to to and return just the output bytes. A thin
wrapper over Ream.convertWithReport that drops the loss report.
Parameters
Section titled “Parameters”The target format.
options?
Section titled “options?”ReamConvertOptions = {}
Font resolution and target-specific options.
Returns
Section titled “Returns”Promise<Uint8Array<ArrayBufferLike>>
The encoded output bytes.
convertWithReport()
Section titled “convertWithReport()”convertWithReport(
to,options?):Promise<ConvertResult>
Defined in: src/core/converter/ream.ts:194
Convert the parsed document to to, returning the output bytes together with
the accumulated Loss report (read-time losses plus any added while
writing). HTML, DOCX and XLSX are produced straight from the interlayer — no
layout, no fonts, zero I/O; SVG and PDF run the layout engine and resolve
fonts first.
Parameters
Section titled “Parameters”The target format. 'xlsx' requires a spreadsheet source.
options?
Section titled “options?”ReamConvertOptions = {}
Font resolution and target-specific options.
Returns
Section titled “Returns”Promise<ConvertResult>
The encoded bytes and the loss report.
Throws
Section titled “Throws”Error when to is 'xlsx' but the source has no grid.
Throws
Section titled “Throws”ConversionLossError when options.strict is set and any loss was recorded.
parse()
Section titled “parse()”
staticparse(bytes,options?):Ream
Defined in: src/core/converter/ream.ts:149
Sniff the format and parse the bytes once into the FlowDoc interlayer.
Parameters
Section titled “Parameters”Uint8Array
The raw document bytes; the format is detected by sniffing.
options?
Section titled “options?”ReamParseOptions = {}
Optional reader-registry override and/or password for an encrypted source.
Returns
Section titled “Returns”Ream
A reusable Ream instance.
Throws
Section titled “Throws”Error when no registered reader recognizes the bytes.