Skip to content
DemoAPI ReferenceFAQ

PDF Generation Template Editor

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

View on GitHub
Guides

Access Forms ​

Retrieves all form widgets on the current page.

This method fetches all form widgets present on the current page of the PDF document and returns a list of corresponding CPDFWidget instances.

tsx
const pdfReaderRef = useRef<CPDFReaderView>(null);

<CPDFReaderView
  ref={pdfReaderRef}
  document={samplePDF}
  configuration={ComPDFKit.getDefaultConfig({})}
/>

// Get the total number of pages in the PDF document
const pageCount = await pdfReaderRef!.current!._pdfDocument.getPageCount();
let allWidgets: CPDFWidget[] = [];
for (let i = 0; i < pageCount1; i++) {
  // Retrieve the page object for the corresponding page number
  const page = pdfReaderRef?.current?._pdfDocument.pageAtIndex(i);
  // Get all forms on the page.
  const widgets = await page?.getWidgets();
  if (widgets) {
    allWidgets = allWidgets.concat(widgets);
  }
}

Related Widgets

ClassDescription
CPDFWidgetBase class for all form widgets
CPDFTextWidgetText input field widget
CPDFSignatureWidgetSignature widget
CPDFRadiobuttonWidgetRadio button widget
CPDFPushbuttonWidgetButton widget
CPDFListboxWidgetList box widget
CPDFCheckboxWidgetCheckbox widget
CPDFComboboxWidgetCombo box widget