Guides · Architecture

Import a document

Opening a package admits it under explicit entry, path, size, and expansion limits, then produces a normalized model plus a compatibility report. Nothing is silently discarded.

Rust WebAssembly Headless
main.rs
use casual_doc_import::{import_package, ImportConfig, ImportMode};
use casual_doc_ooxml::{DocxPackage, PackageLimits};

let bytes = std::fs::read("document.docx")?;
let mut package = DocxPackage::open(&bytes, PackageLimits::default())?;
let outcome = import_package(
    &mut package,
    ImportConfig { mode: ImportMode::Semantic, ..ImportConfig::default() },
)?;

// `outcome.document` is the normalized model.
// Anything unmodeled lands in the compatibility report, not the void.

The admission limits and the package reader they guard are specified in docs/28 — the DOCX package reader; the host-facing import and transaction surfaces live in docs/05 — the SDK API spec.

Dispositions

Every construct the importer meets gets a disposition on two axes — whether the model represents it, and whether the original bytes are retained for write-back. The full rules are the disposition taxonomy.

Disposition
Retention
Meaning
Modeled
Semantic
Represented as a typed model value and re-emitted by the semantic writer.
Preserved
Verbatim bytes
Not yet modeled, but round-tripped unchanged so nothing is lost on save.
Reported
Diagnostic
Recognized and surfaced in the compatibility report for the host to act on.
Rejected
None
Refused at admission — exceeds an explicit entry, size, or expansion limit.

Determinism

The same input, fonts, and engine version produce the same model, layout, and bytes — which is what makes rendering regression-testable.