PSPDFChoiceFormField
Objective-C
@interface PSPDFChoiceFormField : PSPDFFormField
Swift
class ChoiceFormField : PDFFormField
Represents a choice form field in a PDF form. This allows the user to select one of the given options or, if isEdit
is true
, enter their own option value.
-
Unavailable
Not the designated initializer
Undocumented
Declaration
Objective-C
PSPDF_EMPTY_INIT_UNAVAILABLE
-
Unavailable
Not the designated initializer
Undocumented
Declaration
Objective-C
PSPDF_EMPTY_INIT_UNAVAILABLE
-
Inserts a new
PSPDFChoiceFormField
into the document.Note
This new form field will automatically be added to the document.
Declaration
Objective-C
+ (nullable instancetype) insertedChoiceFieldWithType:(PSPDFFormFieldType)type fullyQualifiedName:(nonnull NSString *)fullyQualifiedName documentProvider: (nonnull PSPDFDocumentProvider *)documentProvider formElement:(nonnull PSPDFFormElement *)formElement error:(NSError *_Nullable *_Nullable)error;
Swift
class func insertedChoiceField(with type: PDFFormField.Kind, fullyQualifiedName: String, documentProvider: PSPDFDocumentProvider, formElement: PSPDFFormElement) throws -> Self
Parameters
type
The type of the
PSPDFChoiceFormField
. Can bePSPDFFormFieldTypeListBox
, orPSPDFFormFieldTypeComboBox
.fullyQualifiedName
Each form field is identifiable using its fully qualified name. You can specify any dot separated name.
documentProvider
The document the form field gets inserted in.
formElement
One
PSPDFChoiceFormElement
that will be linked to this form field. The form elements are the visual representation of the form on the page. If the form elements aren’t yet added to the document provider, they will be added.error
The error, if any happens.
Return Value
Either an instance of
PSPDFChoiceFormField
or nil if an error occurs. -
If set, the field is a combo box; if clear, the field is a list box.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isCombo;
Swift
var isCombo: Bool { get }
-
If set, the combo box shall include an editable text box as well as a drop-down list; if clear, it shall include only a drop-down list. This flag shall be used only if the Combo flag is set.
Declaration
Objective-C
@property (nonatomic) BOOL isEdit;
Swift
var isEdit: Bool { get set }
-
(PDF 1.4) If set, more than one of the field’s option items may be selected simultaneously; if clear, at most one item shall be selected.
Declaration
Objective-C
@property (nonatomic) BOOL isMultiSelect;
Swift
var isMultiSelect: Bool { get set }
-
(PDF 1.5) If set, the new value shall be committed as soon as a selection is made (commonly with the pointing device). In this case, supplying a value for a field involves three actions: selecting the field for fill-in, selecting a choice for the fill-in value, and leaving that field, which finalizes or “commits” the data choice and triggers any actions associated with the entry or changing of this data. If this flag is on, then processing does not wait for leaving the field action to occur, but immediately proceeds to the third step. This option enables applications to perform an action once a selection is made, without requiring the user to exit the field. If clear, the new value is not committed until the user exits the field.
Declaration
Objective-C
@property (nonatomic) BOOL commitOnSelChange;
Swift
var commitOnSelChange: Bool { get set }
-
(PDF 1.4) If set, text entered in the field shall not be spellchecked. This flag shall not be used unless the Combo and Edit flags are both set.
Declaration
Objective-C
@property (nonatomic) BOOL doNotSpellCheck;
Swift
var doNotSpellCheck: Bool { get set }
-
An array of options that will be presented to the user. This can also be used to modify the options presented to the user.
Note
If you save the document after modifying options, the new options will be preserved in the PDF file.Declaration
Objective-C
@property (nonatomic, copy) NSArray<PSPDFFormOption *> *_Nonnull options;
Swift
var options: [PDFFormOption] { get set }
-
(Sometimes required, otherwise optional; PDF 1.4) For choice fields that allow multiple selection (MultiSelect flag set), an array of integers, sorted in ascending order, representing the zero-based indices in the Opt array of the currently selected option items. This entry shall be used when two or more elements in the Opt array have different names but the same export value or when the value of the choice field is an array. This entry should not be used for choice fields that do not allow multiple selection. If the items identified by this entry differ from those in the V entry of the field dictionary (see discussion following this Table), the V entry shall be used.
Note
Setting selected indices clearscustomText
.Declaration
Objective-C
@property (nonatomic, copy, nullable) NSIndexSet *selectedIndices;
Swift
var selectedIndices: IndexSet? { get set }
-
For combo boxes only, is the selection a default or custom value
Declaration
Objective-C
@property (nonatomic, readonly) BOOL customSelection;
Swift
var customSelection: Bool { get }
-
Custom text.
Note
Setting custom text clearsselectedIndices
.Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *customText;
Swift
var customText: String? { get set }
-
Clears the options cache so that they are fetched again from Core and cached.