Skip to content

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 → FlowDoc
const 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.

readonly flow: FlowDoc

Defined in: src/core/converter/ream.ts:133

The interlayer — the parsed, format-neutral document tree.


readonly losses: readonly Loss[]

Defined in: src/core/converter/ream.ts:135

Losses recorded while reading the source.


readonly sheet: 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.

get format(): string

Defined in: src/core/converter/ream.ts:165

The source format id ('docx', 'xlsx', …).

string

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.

ReamTarget

The target format.

ReamConvertOptions = {}

Font resolution and target-specific options.

Promise<Uint8Array<ArrayBufferLike>>

The encoded output bytes.


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.

ReamTarget

The target format. 'xlsx' requires a spreadsheet source.

ReamConvertOptions = {}

Font resolution and target-specific options.

Promise<ConvertResult>

The encoded bytes and the loss report.

Error when to is 'xlsx' but the source has no grid.

ConversionLossError when options.strict is set and any loss was recorded.


static parse(bytes, options?): Ream

Defined in: src/core/converter/ream.ts:149

Sniff the format and parse the bytes once into the FlowDoc interlayer.

Uint8Array

The raw document bytes; the format is detected by sniffing.

ReamParseOptions = {}

Optional reader-registry override and/or password for an encrypted source.

Ream

A reusable Ream instance.

Error when no registered reader recognizes the bytes.