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

Edit Form Fields

ComPDF React Native SDK supports updating form field appearance and content by modifying form field object properties via API. The following examples demonstrate how to modify form field properties such as border color, fill color, text content, etc.:

tsx
const document = pdfReaderRef.current?._pdfDocument;
const widgets = await document.pageAtIndex(1)?.getWidgets();
final widget = widgets[0];

widget.update({
  text: 'ComPDF-RN',
  title: 'ComPDF-RN TextField',
  fillColor: '#A2E195',
  borderColor: '#ED0E0E',
  fontColor: '#F55D1C',
  fontSize: 16,
  familyName: 'Times',
  styleName: 'Bold',
  borderWidth: 5
});
await document?.updateWidget(widget);

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