Skip to content
ComPDF
DemoFAQ
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

The ComPDF Flutter SDK supports content editor callbacks and listener events for style panels and editable content selection.

Available Callbacks and Events

TypeNameTrigger TimingPayload
Reader callbackonContentEditorStyleDialogDismissedCallbackContent editor style dialog is dismissedCPDFEditAreaType type
Listener eventCPDFEvent.editorSelectionSelectedEditable content is selectedCPDFEditArea
Listener eventCPDFEvent.editorSelectionDeselectedEditable content is deselectedCPDFEditArea?

Example Usage

dart
late CPDFReaderWidgetController readerController;

void onEditorSelectionSelected(dynamic editArea) {
  debugPrint('Content editor selected: $editArea');
}

void onEditorSelectionDeselected(dynamic editArea) {
  debugPrint('Content editor deselected: $editArea');
}

CPDFReaderWidget(
  document: documentPath,
  configuration: configuration,
  onCreated: (controller) {
    readerController = controller;
    readerController.addEventListener(
      CPDFEvent.editorSelectionSelected,
      onEditorSelectionSelected,
    );
    readerController.addEventListener(
      CPDFEvent.editorSelectionDeselected,
      onEditorSelectionDeselected,
    );
  },
  onContentEditorStyleDialogDismissedCallback: (CPDFEditAreaType type) {
    debugPrint('Content editor style dialog dismissed: ${type.name}');
  },
);

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

Remove Event Listeners

dart
readerController.removeEventListener(
  CPDFEvent.editorSelectionSelected,
  onEditorSelectionSelected,
);