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.
Content editing uses CPDFEvent for selection changes and the content-editor History Manager for undo/redo state.
| Event | Event data | Trigger |
|---|---|---|
CPDFEvent.EDITOR_SELECTION_SELECTED | CPDFEditArea | Editable text, image, or path content is selected. |
CPDFEvent.EDITOR_SELECTION_DESELECTED | CPDFEditArea | null | The content-editor selection is cleared. |
| Scenario | Registration API | Callback parameters | Replacement rule |
|---|---|---|---|
| Content-editor undo/redo state | pdfReaderRef.current?. | pageIndex: number, canUndo: boolean, canRedo: boolean | Setting again replaces the previous callback. |
const reader = pdfReaderRef.current;
if (reader) {
const editorHistory = reader._editManager.historyManager;
const initialCanUndo = await editorHistory.canUndo();
const initialCanRedo = await editorHistory.canRedo();
console.log('Initial editor history:', initialCanUndo, initialCanRedo);
editorHistory.setOnHistoryStateChangedListener(
(pageIndex, canUndo, canRedo) => {
console.log('Editor history:', pageIndex, canUndo, canRedo);
},
);
}EDITOR_SELECTION_SELECTED can be CPDFEditTextArea, CPDFEditImageArea, or CPDFEditArea with type === CPDFEditType.PATH. On Android, editor deselection normally returns null; on iOS it can return the deselected area. RN does not define a dedicated path-area class.
Each Manager keeps one callback and does not emit an initial value. Query canUndo() and canRedo() when initializing controls. On iOS, the content-editor listener may also fire after a page change to report the new page's undo/redo state.
The current TypeScript class exposes _annotationsHistoryManager and _editManager, but their leading underscores indicate lower API stability. A future SDK version may replace them with formal public getters.
See Undo and Redo for the operation APIs.