Fill Form Fields


ComPDFKit PDF SDK fully supports the AcroForm standard, and forms can be viewed and filled inside the CPDFView.


To fill in a text form element, tap it and then type text using either the onscreen keyboard or an attached hardware keyboard. Then tap either the Done button above the keyboard or any blank area on the page to deselect the form element, which will commit the changes.



To set the value of a choice form element (a list or combo box), tap the element, and then select an item from the list, or type in a custom item.



To enable or disable a checkbox form element, tap it to toggle its state. And you can set the selection of a radio button form element by tapping the desired item.



While a form element is selected (focused), the left and right arrows above the keyboard may be used to move the focus sequentially between all the form elements on the page.

The following example that demonstrates how form fields can be queried and filled with code:


int pageNumber = 0;
CPDFPage page = document.pageAtIndex(pageNumber);
List<CPDFAnnotation> annotations = page.getAnnotations();
for (CPDFAnnotation annotation:annotations) {
 if (annotation.getType() == CPDFAnnotation.Type.WIDGET) {
   if (((CPDFWidget) annotation).getWidgetType() == CPDFWidget.WidgetType.Widget_CheckBox) {
    ((CPDFCheckboxWidget) annotation).setChecked(true);
   if (((CPDFWidget) annotation).getWidgetType() == CPDFWidget.WidgetType.Widget_TextField) {
    ((CPDFTextWidget) annotation).setText("Hello world");