PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
The content editor lets users edit text and images directly on the PDF page — add text, add images, and modify existing content. It is coordinated by the engine's content_edit_manager with a dedicated history manager, exposed to the UI through the core bridge.
The content-editing engine lives in the closed-source Core (
packages/core/src/editor/). The UI layer drives it through the bridge and mirrors state in the stores.
UI.disableDocumentEditorSave(); // useViewer.setDocumentEditorSaveStatus(false)
UI.enableDocumentEditorSave(); // useViewer.setDocumentEditorSaveStatus(true)
UI.disableDocumentEditorSaveAs(); // useViewer.setDocumentEditorSaveAsStatus(false)
UI.enableDocumentEditorSaveAs(); // useViewer.setDocumentEditorSaveAsStatus(true)Toggle the documentEditorSaveStatus / documentEditorSaveAsStatus flags in the viewer store, controlling whether the Save / Save-As actions are available in the document editor.
UI.saveDocumentEditor() (async) Persist the document-editor changes and reload the document.
await UI.saveDocumentEditor();Internally (in apis/saveDocumentEditor.js):
core.saveDocumentEdit() to get a newUrl; returns early if falsy.useDocument.resetSetting(), useDocument.setToolState('').setActiveToolMode('view'), setToolbarGroup('toolbarGroup-View'), setActiveHeaderGroup('default').setUpload(true), setUploadLoading(true)), preserves the old scale.useDocument.setCurrentPdfData(newUrl), refreshes totalPages via core.getPagesCount(), outlines via core.getOutlines(), resets page to 1.core.switchScrollMode / core.switchSpreadMode / core.scaleChanged.setUploadLoading(false).| Store | Field | Purpose |
|---|---|---|
| viewer | contentEditorType | Editor type ('text'). |
| viewer | documentEditorSaveStatus / documentEditorSaveAsStatus | Save / save-as availability. |
| document | documentEditor | { operationList[], pageList[], selectedPageList[] }. |
| document | canUndo / canRedo | { content, annotation } undo/redo flags. |
useHistoryListener (in HeaderItemsListener.js) bridges the engine's contentEditHistoryChanged / historyChanged events into useDocument.setCanUndo / setCanRedo.
DocumentEditorContainer — the page editor surface, shown when the active tool mode is document.ContentEditorPanel — content-editor selection properties (right panel, eager-loaded).ContentEditorToolBar — content-editor toolbar.ContentEditorPopup — the content-editor context menu (see Popups).Related dialogs: ContentEditorPreventDialog, DocEditorPreventDialog.
The core bridge exposes on instance.Core:
| Function | Purpose |
|---|---|
switchAnnotationEditorMode | Switch the editor mode. |
setContentEditorProperty | Set a content-editor property. |
getContentEditManager | Get the content-edit coordinator. |
getContentEditHistoryManager | Get the content-edit history manager. |
addEditorImage | Add an image to the editor. |
getCropedPageImage | Get a cropped page image. |
saveDocumentEdit | Save edits and return a new URL. |
UI.disableDocumentEditorSaveAs();await UI.saveDocumentEditor();