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. The page editor lets users insert, delete, rotate, move and extract pages. This guide covers both.
Content editing belongs to the Core
ContentEditManager(documentViewer.getContentEditManager()), with its own history manager. The UI drives it through tools and panels.
Content editing is the toolbar group toolbarGroup-EditText. Switching to it activates the content editing tool ContentEditTool:
UI.setToolbarGroup('toolbarGroup-EditText');The tools of the group are the grouped items editTextGroupedItems. Selecting a text block shows the content edit popup (UI.contentEditPopup) and the properties panel textEditingPanel.
| API | Purpose |
|---|---|
contentEditManager.startContentEditMode() / endContentEditMode() | Enter / leave content editing. |
contentEditManager.isInContentEditMode() | Whether content editing is active. |
contentEditManager.getContentBoxes(pageNumber) | The text and image blocks of a page. |
contentEditManager.getSelectedContentBox() | The selected block. |
contentEditManager.getContent(box) / setContent(box, content) | Read / write the text of a block. |
documentViewer.getContentEditHistoryManager() | Undo / redo of content editing; fires undoRedoStatusChanged with { canUndo, canRedo }. |
const contentEditManager = instance.Core.documentViewer.getContentEditManager();
console.log(contentEditManager.isInContentEditMode());await UI.enterPageEditorMode(); // open the page editor
UI.isInPageEditorMode(); // => true
await UI.savePageEditor(); // apply the changes to the document
await UI.exitPageEditorMode(); // leave without saving| API | Purpose |
|---|---|
enterPageEditorMode() | Open the page editor (toolbar group toolbarGroup-Document). Resolves when the editor is ready. |
exitPageEditorMode() | Discard the changes and return to the View group. |
isInPageEditorMode() | Whether the page editor is open. |
savePageEditor() | Apply the changes to the document shown in the viewer. |
enablePageEditorSave() / disablePageEditorSave() | Show / hide the Save button of the page editor. |
enablePageEditorSaveAs() / disablePageEditorSaveAs() | Show / hide the Save As button of the page editor. |
While the page editor is open, the header page-editor-header replaces the top header.
| State | Purpose |
|---|---|
| Content editing | Whether content editing is active, the selected blocks, the text properties shown in textEditingPanel. |
| Page editor | Whether the page editor is open, the pages and the selection in the editor. |
| Undo / redo | Mirrors the history managers of the Core. |
insertPageModal, mergePagesModal, deletePagesModal, extractPagesModal, movePagesModal).textEditingPanel — the properties of the selected text block.UI.disablePageEditorSaveAs();await UI.enterPageEditorMode();
// … the user edits the pages …
await UI.savePageEditor();const history = instance.Core.documentViewer.getContentEditHistoryManager();
history.addEventListener('undoRedoStatusChanged', ({ canUndo, canRedo }) => {
console.log(canUndo, canRedo);
});