ComPDFKit 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 demonstrates how form fields can be queried and filled with code:
CPDFDocument document = CPDFDocument.InitWithFilePath("filePath");
CPDFPage page = document.PageAtIndex(0);
List annotList = page.GetAnnotations();
foreach (CPDFAnnotation annot in annotList)
{
if (annot.Type==C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET)
{
CPDFWidget widget = annot as CPDFWidget;
switch(widget.WidgeType)
{
case C_WIDGET_TYPE.WIDGET_TEXTFIELD:
{
CPDFTextWidget text = widget as CPDFTextWidget;
text.SetText("test");
text.UpdateFormAp();
}
break;
case C_WIDGET_TYPE.WIDGET_RADIOBUTTON:
{
CPDFRadioButtonWidget radio = widget as CPDFRadioButtonWidget;
radio.SetChecked(true);
radio.UpdateFormAp();
}
break;
case C_WIDGET_TYPE.WIDGET_LISTBOX:
{
CPDFListBoxWidget listBox = widget as CPDFListBoxWidget;
listBox.SelectItem(0);
listBox.UpdateFormAp();
}
break;
default:
break;
}
}
}