Quickstart
Four concepts recur in every PDF integration and are worth understanding before installing Univer PDFs:
- Plugin
- Snapshot and data model
- Command
- Facade API
Basic concepts
Plugins
Univer PDFs consists of plugins. UniverPdfsPlugin registers the UNIVER_PDF unit model and the durable PDF commands. UniverPdfsUIPlugin adds the browser viewer and, by default, the editing controls. Add the print, exchange, or collaboration packages only when the application needs those capabilities.
Both plugins run on the core, rendering, design, and UI services that Univer shares across products. These services are technical dependencies of the PDF application, and using the PDF plugins does not require experience with another Univer product.
Snapshot and data model
A PDF unit is persisted as an IPdfUnitData snapshot. The document field holds the source baseline, which is either imported or blank. Accepted edits are stored in editState instead, so the baseline itself is never rewritten in place.
Call pdf.save() to obtain the complete current snapshot. pdf.getDocument() returns the source baseline, so user edits must be persisted with save().
Command
Changes at runtime are applied through commands, which keeps validation, view updates, edit history, and export intent on the same path. PDF Facade methods prepare the command parameters and execute the commands.
Caution
Do not modify the snapshot or source document of a running PDF unit directly. Use PDF Facade methods or registered commands instead.
Facade API
Import @univerjs-pro/pdfs/facade after the core Facade entry to add the PDF APIs to FUniver. The entry provides methods such as createPdf(), getActivePdf(), and getPdf().
For complete setup instructions and examples, see Using the PDF Facade API.
Continue to Installation & Basic Usage.
How is this guide?