Guides
Content Editor
The ComPDF React Native SDK supports a variety of content editing events. Commonly used content editing events include:
| Event Name | Description |
|---|---|
| onContentEditorStyleDialogDismissed | Triggered when the content editor style dialog is dismissed. Returns an event object that contains the content editor type. |
| CPDFEvent.EDITOR_SELECTION_SELECTED | Triggered when a user selects a content edit element. Returns the selected edit element data. |
| CPDFEvent.EDITOR_SELECTION_DESELECTED | Triggered when a user deselects a content edit element. Returns the deselected edit element data. |
To listen for these events, pass the dismissal callback when creating CPDFReaderView, or call the event listener functions after the view is created:
tsx
<CPDFReaderView
ref={pdfReaderRef}
document={samplePDF}
configuration={configuration}
onContentEditorStyleDialogDismissed={(event) => {
console.log('Content editor style dialog dismissed:', event.type);
}}
/>onContentEditorStyleDialogDismissed returns an event object with the following structure:
tsx
{
type: 'editorText' | 'editorImage';
}Other content editing events can be listened to after creating the CPDFReaderView:
tsx
pdfReaderRef.current?.addEventListener(
CPDFEvent.EDITOR_SELECTION_SELECTED,
(editArea) => {
// 'editArea' is a CPDFEditArea object
// text : CPDFEditTextArea object
// image : CPDFEditImageArea object
// path : CPDFEditPathArea object
}
);
pdfReaderRef.current?.addEventListener(
CPDFEvent.EDITOR_SELECTION_DESELECTED,
(editArea) => {
// 'editArea' is a CPDFEditArea object, may be null
}
);