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

Forms

Use these callbacks and events to synchronize form property panels and observe form-field creation and selection.

Form APIs

Callback or eventEvent dataTrigger
onFormStyleDialogDismissed{ type }The form properties panel closes.
CPDFEvent.FORM_FIELDS_CREATEDCPDFWidgetA form field is created.
CPDFEvent.FORM_FIELDS_SELECTEDCPDFWidgetA form field is selected.
CPDFEvent.FORM_FIELDS_DESELECTEDCPDFWidget | nullA form field is deselected.

The public TypeScript contract for form-field deselection is nullable; handle a null value before accessing the widget.

tsx
const onFormFieldCreated = (widget: CPDFWidget) => {
  console.log('Created form field:', widget.type);
};

pdfReaderRef.current?.addEventListener(
  CPDFEvent.FORM_FIELDS_CREATED,
  onFormFieldCreated,
);

These events do not provide form update or delete events, and they do not report save failures.

For listener lifecycle handling, see Annotations. Custom form-field actions are covered in Custom Annotation Creation Workflows.