Skip to content

Forms

Foxit PDF SDK for iOS provides PDF AcroForm support via Core SDK: read, fill, import/export, and manage form fields.

UI Extensions built-in forms

With the full reader (UI Extensions), users can fill text fields, checkboxes, radio buttons, and other controls in the UI—no extra code required.

Core classes

ClassDescription
FSFormForm object for all interactive fields
FSFieldForm field (text, checkbox, radio, list, combo, etc.)
FSControlControl instance for field appearance and interaction on a page

Field type constants

ConstantDescription
FSFieldTypeUnknownUnknown
FSFieldTypePushButtonButton
FSFieldTypeCheckBoxCheckbox
FSFieldTypeRadioButtonRadio button
FSFieldTypeComboBoxCombo box
FSFieldTypeListBoxList box
FSFieldTypeTextFieldText field
FSFieldTypeSignatureSignature field

Example: read and fill fields

objc
#import <FoxitRDK/FSPDFObjC.h>

FSPDFDoc *doc = [[FSPDFDoc alloc] initWithPath:@"path/to/form.pdf"];
[doc load:nil];

BOOL hasForm = [doc hasForm];
if (!hasForm) return;

FSForm *form = [[FSForm alloc] initWithDocument:doc];

// Enumerate fields
int fieldCount = [form getFieldCount:@""];
for (int i = 0; i < fieldCount; i++) {
    FSField *field = [form getField:i filter:@""];
    NSString *name = [field getName];
    FSFieldType type = [field getType];
    NSString *value = [field getValue];

    NSLog(@"字段: %@, 类型: %d, 值: %@", name, (int)type, value);
}

// Set text field value
FSField *textField = [form getField:0 filter:@""];
[textField setValue:@"填写的内容"];

[doc saveAs:@"path/to/output.pdf" saveFlags:FSPDFDocSaveFlagNormal];

Example: import and export form data

objc
FSForm *form = [[FSForm alloc] initWithDocument:doc];

// Export to XML
BOOL exported = [form exportToXML:@"path/to/formdata.xml"];

// Import from XML
BOOL imported = [form importFromXML:@"path/to/formdata.xml"];

[doc saveAs:@"path/to/output.pdf" saveFlags:FSPDFDocSaveFlagNormal];

API reference

See the API reference for FSForm, FSField, and FSControl.