Fill Form Fields
ComPDFKit PDF SDK fully supports the AcroForm standard, and forms can be viewed and filled inside the CPDFView
.
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 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");
}
}
}