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

Edit Form Fields

You can update the appearance and content of form fields by modifying the properties of form field objects. The following example demonstrates how to modify form field properties such as border color, fill color, text content, etc.:

dart
final page = controller.document.pageAtIndex(pageIndex);
final widgets = await page.getWidgets();
final widget = widgets[0];

widget.title = 'TextFields---ComPDF';
widget.fillColor = Colors.green;
widget.borderColor = Colors.red;
widget.borderWidth = 10;
widget.text = 'Updated Text';
widget.fontColor = Colors.black;
widget.fontSize = 20.0;
widget.alignment = CPDFAlignment.center;
widget.isMultiline = true;
widget.familyName = 'Times';
widget.styleName = 'Bold';

await controller.document.updateWidgets(widget);

For more modifiable properties, please refer to the definition of each form field class, such as CPDFTextWidget, CPDFCheckBoxWidget, etc.