Skip to content
ComPDF
DemoAPI ReferenceFAQ
New Release

Open-Source PDF SDK & AI Document Processing

Get the full self-hosted SDK and AI document processing on GitHub. One-click deploy to quickly build your document workflows.

Guides

Content Editor

ComPDF React Native SDK supports content editor callbacks and listener events for style panels and editable content selection.

Available Callbacks and Events

TypeNameTrigger TimingPayload
Reader callbackonContentEditorStyleDialogDismissedContent editor style dialog is dismissed{ type } event object
Listener eventCPDFEvent.EDITOR_SELECTION_SELECTEDEditable content is selectedCPDFEditArea
Listener eventCPDFEvent.EDITOR_SELECTION_DESELECTEDEditable content is deselectedCPDFEditArea | null

Example Usage

tsx
const onEditorSelectionSelected = (editArea: CPDFEditArea) => {
  console.log('Content editor selected:', editArea.type);
};

const onEditorSelectionDeselected = (editArea: CPDFEditArea | null) => {
  console.log('Content editor deselected:', editArea?.type);
};

<CPDFReaderView
  ref={pdfReaderRef}
  document={samplePDF}
  configuration={configuration}
  onViewCreated={() => {
    pdfReaderRef.current?.addEventListener(
      CPDFEvent.EDITOR_SELECTION_SELECTED,
      onEditorSelectionSelected,
    );
    pdfReaderRef.current?.addEventListener(
      CPDFEvent.EDITOR_SELECTION_DESELECTED,
      onEditorSelectionDeselected,
    );
  }}
  onContentEditorStyleDialogDismissed={(event) => {
    console.log('Content editor style dialog dismissed:', event.type);
  }}
/>

CPDFEvent.EDITOR_SELECTION_SELECTED returns CPDFEditArea and its subclasses, such as CPDFEditTextArea, CPDFEditImageArea, and CPDFEditPathArea. CPDFEvent.EDITOR_SELECTION_DESELECTED may return null.

Remove Event Listeners

tsx
pdfReaderRef.current?.removeEventListener(
  CPDFEvent.EDITOR_SELECTION_SELECTED,
  onEditorSelectionSelected,
);