Skip to content
ComPDF
Guides

内容编辑

ComPDF Flutter SDK 支持多种内容编辑事件监听,以下是常用的内容编辑事件:

事件名称描述
editorSelectionSelected当用户选中内容编辑元素时触发,返回选中的内容编辑元素数据。
editorSelectionDeselected当用户取消选中内容编辑元素时触发,返回取消选中的内容编辑元素数据。

要监听这些事件,可以在创建 CPDFReaderWidget 后通过 CPDFReaderWidgetController 调用函数。例如:

dart
    controller.addEventListener(CPDFEvent.editorSelectionSelected, (event) {
      // event 为 CPDFEditArea 对象
      // text : CPDFEditTextArea 对象
      // image : CPDFEditImageArea 对象
      // path : CPDFEditPathArea 对象
      print(jsonEncode(event));
    });

    controller.addEventListener(CPDFEvent.editorSelectionDeselected, (event) {
      // event 为 CPDFEditArea 对象,可能为空
      print(jsonEncode(event));
    });