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
- Set
autoShowNoteEditDialogtofalse. - The user selects the Note tool and taps the page.
- The SDK creates a Note annotation and returns it through
onAnnotationCreationPreparedCallback. - Your Flutter UI shows a custom dialog.
- Save the user input to the returned annotation. If the user cancels, remove the annotation.
Configuration
dart
CPDFConfiguration(
annotationsConfig: CPDFAnnotationsConfig(
autoShowNoteEditDialog: false,
),
);| Option | Type | Default | Description |
|---|---|---|---|
autoShowNoteEditDialog | bool | true | Whether to automatically show the SDK default edit dialog after a Note annotation is created |
Difference from interceptNoteAction
| Option | Scenario | Description |
|---|---|---|
autoShowNoteEditDialog | After creating a new Note annotation | Controls whether the default Note edit dialog is shown automatically |
interceptNoteAction | When tapping an existing Note annotation | Controls 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.
}
},
);| Parameter | Description |
|---|---|
type | The annotation type being prepared or created. For this workflow, it is CPDFAnnotationType.note |
annotation | The 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.