Skip to content
ComPDF
DemoAPI ReferenceFAQ

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub
Guides

Custom Annotation Creation Workflows

These APIs have different effects on the built-in SDK workflow:

Workflow APIs

GoalAPIEffect on default behavior
Observe a completed annotation creationCPDFEvent.ANNOTATIONS_CREATEDDoes not change default behavior.
Replace the Signature, Image, Stamp, Link, or Note creation UIonAnnotationCreationPreparedAfter disabling the corresponding built-in UI, the application must complete or cancel the workflow.
Replace the action for an existing Note or LinkonInterceptAnnotationActionCallbackThe SDK no longer performs the default edit or navigation action.
Replace selected form-field actionsonInterceptWidgetActionCallbackThe SDK no longer performs the default action for intercepted field types.

Customize Annotation Creation

Annotation typeConfiguration to disableannotation parameterNext application action
CPDFAnnotationType.SIGNATUREautoShowSignPicker: falsenullSelect an image, then call prepareNextSignature().
CPDFAnnotationType.STAMPautoShowStampPicker: falsenullSelect a stamp, then call prepareNextStamp().
CPDFAnnotationType.PICTURESautoShowPicPicker: falsenullSelect an image, then call prepareNextImage().
CPDFAnnotationType.LINKautoShowLinkDialog: falseCreated CPDFLinkAnnotationSet action and call _pdfDocument.updateAnnotation(); remove it on cancel.
CPDFAnnotationType.NOTEautoShowNoteEditDialog: falseCreated CPDFNoteAnnotationSet content and call _pdfDocument.updateAnnotation(); remove it on cancel.
tsx
const configuration = ComPDFKit.getDefaultConfig({
  annotationsConfig: {
    autoShowSignPicker: false,
    autoShowStampPicker: false,
    autoShowPicPicker: false,
    autoShowLinkDialog: false,
    autoShowNoteEditDialog: false,
  },
});

Signature, Stamp, and Image annotations have not yet been placed when the callback runs:

tsx
await pdfReaderRef.current?.prepareNextSignature(signaturePath);
await pdfReaderRef.current?.prepareNextImage(imagePath);
await pdfReaderRef.current?.prepareNextStamp({
  standardStamp: CPDFStandardStamp.APPROVED,
});

Link and Note objects already exist when the callback runs. Updating the JavaScript object alone does not persist the change; call updateAnnotation() or removeAnnotation(). See Create Annotations for the complete custom Note confirm/cancel workflow.

Intercept Actions on Existing Annotations

Set interceptNoteAction or interceptLinkAction to true in annotationsConfig. The application must then handle Note editing, web links, or page navigation in onInterceptAnnotationActionCallback. Do not enable interception if you only need passive observation.

Intercept Form-Field Actions

List only the required CPDFWidgetType values in formsConfig.interceptFormWidgetActions. After changing the returned CPDFWidget, call pdfReaderRef.current?._pdfDocument.updateWidget(widget). Use interceptAllFormWidgetActions: true only when the application implements every form-field behavior.