PDF Unit Data

Understand the persisted IPdfUnitData contract and the boundary between imported PDF content and durable edits.

IPdfUnitData

IPdfUnitData is the snapshot persisted for a single UNIVER_PDF unit. The schema is univer-pdf-unit, the current schema version is 1, and revision numbers start at 1.

PropertyTypePurpose
schema'univer-pdf-unit'Stable identifier for the PDF unit schema
schemaVersion1Current PDF unit schema version
idstringIdentity shared by storage, collaboration, resources, and export
revnumberAuthoritative revision of the unit
namestringPDF name shown to users
sourceDocumentRefIPdfSourceDocumentRefImmutable provenance of the imported PDF artifact
documentIPdfDocumentImported baseline, or the baseline of a blank document
editStateIPdfDurableEditStateAccepted and persisted editing intent
documentShell?IPdfDocumentShellSmall page directory and fragment index for block-backed PDFs
fragmentIndex?IPdfUnitFragmentIndexLogical mapping from pages and shared data to stored fragments
resourceBindings?Record<string, PdfDurableResourceBinding>Durable native or Univer-managed resource bindings
fragmentBindings?Record<string, IPdfFragmentArtifactBinding>Runtime file bindings for independently loaded fragments
capabilityReport?IPdfCapabilityReportImport and runtime decisions about supported actions and fallbacks
metadata?Record<string, PdfJsonValue>Application or integration metadata

Baseline and edit layer

The imported document is an immutable baseline. Editing never rewrites it in place. Text replacements, inserted objects, page changes, source suppressions, and managed resources are recorded in editState, which is then projected over the baseline for rendering and export.

Separating the two layers preserves the provenance of native PDF content and lets exporters decide which source operations to copy, suppress, or replace.

Choose the correct view

pdf.getDocument() returns the imported baseline. pdf.save() returns the complete unit snapshot with its durable edit state. Advanced integrations can obtain the current projection from pdf.getModel().getMaterializedDocument().

Create and persist a snapshot

TypeScript
const pdf = univerAPI.createPdf({ name: 'Untitled contract' })const page = pdf.getPageByIndex(0)page?.insertTextBox({  text: 'Draft',  left: 36,  top: 36,})const snapshot = pdf.save()await applicationStorage.save(snapshot.id, snapshot)

Restore the complete snapshot through the Facade:

TypeScript
const snapshot = await applicationStorage.load('pdf-unit-id')const pdf = univerAPI.createPdf(snapshot)

After the unit is running, do not modify a snapshot object. Use Facade methods or registered commands instead, so that validation, undo and redo, collaboration, and export intent remain consistent.

Block-backed PDFs

Large PDFs, or PDFs stored remotely, can use documentShell, fragmentIndex, and fragmentBindings. The shell keeps page sizes, order, labels, and block IDs available before any page body is loaded. Providers materialize page fragments and shared fragments when the UI needs them.

These fields are exchange and storage contracts. Application code normally obtains them from the PDF exchange or collaboration services and persists them unchanged.

How is this guide?

© 2026 DreamNum Co., Ltd.