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

Custom Note Annotation Creation Dialog

ComPDF Flutter SDK allows you to control whether the SDK automatically shows the default edit dialog after a Note annotation is created. Disable the default dialog, receive the created Note annotation in Flutter, and present your own editing UI.

Workflow

  1. Set autoShowNoteEditDialog to false.
  2. The user selects the Note tool and taps the page.
  3. The SDK creates a Note annotation and returns it through onAnnotationCreationPreparedCallback.
  4. Your Flutter UI shows a custom dialog.
  5. Save the user input to the returned annotation. If the user cancels, remove the annotation.

Configuration

dart
CPDFConfiguration(
  annotationsConfig: CPDFAnnotationsConfig(
    autoShowNoteEditDialog: false,
  ),
);
OptionTypeDefaultDescription
autoShowNoteEditDialogbooltrueWhether to automatically show the SDK default edit dialog after a Note annotation is created

Difference from interceptNoteAction

OptionScenarioDescription
autoShowNoteEditDialogAfter creating a new Note annotationControls whether the default Note edit dialog is shown automatically
interceptNoteActionWhen tapping an existing Note annotationControls whether to intercept the default edit action for an existing Note

Callback API

dart
CPDFReaderWidget(
  document: documentPath,
  configuration: configuration,
  onAnnotationCreationPreparedCallback: (
    CPDFAnnotationType type,
    CPDFAnnotation? annotation,
  ) {
    if (type == CPDFAnnotationType.note && annotation is CPDFNoteAnnotation) {
      // Show your custom note dialog.
    }
  },
);
ParameterDescription
typeThe annotation type being prepared or created. For this workflow, it is CPDFAnnotationType.note
annotationThe created Note annotation object. Update or remove it according to the result of your custom dialog

Note: When the callback is triggered, the Note annotation has already been added to the PDF page. If the user cancels your custom dialog, remove the created Note annotation to avoid leaving an empty annotation on the page.