pub struct FormField {Show 16 fields
pub name: String,
pub field_type: FormFieldType,
pub value: Option<String>,
pub default_value: Option<String>,
pub flags: FormFieldFlags,
pub tooltip: Option<String>,
pub alternate_name: Option<String>,
pub mapping_name: Option<String>,
pub max_len: Option<u32>,
pub options: Vec<ChoiceOption>,
pub appearance_state: Option<String>,
pub children: Vec<FormField>,
pub controls: Vec<FormControl>,
pub dirty: bool,
pub selected_indices: Vec<usize>,
pub additional_actions: Option<AdditionalActions>,
}Expand description
A parsed interactive form field.
Fields§
§name: StringFully qualified field name (parent.child format).
field_type: FormFieldTypeField type.
value: Option<String>Current value (/V).
default_value: Option<String>Default value (/DV).
flags: FormFieldFlagsField flags (/Ff).
tooltip: Option<String>Tooltip (/TU).
alternate_name: Option<String>Alternate field name for display (/TU, same as tooltip — upstream uses this).
mapping_name: Option<String>Mapping name for export (/TM).
max_len: Option<u32>For text fields: maximum length (/MaxLen).
options: Vec<ChoiceOption>For choice fields: options (/Opt).
appearance_state: Option<String>For button fields: checked/appearance state (/AS).
children: Vec<FormField>Child fields (for hierarchical fields).
controls: Vec<FormControl>Widget controls associated with this field.
dirty: boolWhether the field value has been modified since parsing.
selected_indices: Vec<usize>Selected indices for choice fields (/I).
additional_actions: Option<AdditionalActions>Additional actions for the field (/AA).
Implementations§
Source§impl FormField
impl FormField
Sourcepub fn set_value(&mut self, value: FieldValue) -> Result<(), DocError>
pub fn set_value(&mut self, value: FieldValue) -> Result<(), DocError>
Set the field’s value with type and constraint validation.
Returns an error if:
- The value type does not match the field type (e.g.
Boolon aTextfield). - A text value exceeds
/MaxLen. - A choice index is out of range.
Sourcepub fn controls(&self) -> &[FormControl]
pub fn controls(&self) -> &[FormControl]
Returns the widget controls associated with this field.
Sourcepub fn needs_appearance(&self) -> bool
pub fn needs_appearance(&self) -> bool
Returns true if the field has been modified and its appearance stream
needs regeneration.
Sourcepub fn reset_to_default(&mut self)
pub fn reset_to_default(&mut self)
Reset the field to its default value (/DV), or clear if none.
Sourcepub fn selected_item_count(&self) -> usize
pub fn selected_item_count(&self) -> usize
Returns the number of currently selected items.
Corresponds to upstream CPDF_FormField::CountSelectedItems().
Sourcepub fn count_selected_items(&self) -> usize
pub fn count_selected_items(&self) -> usize
Upstream-aligned alias for selected_item_count().
Corresponds to upstream CPDF_FormField::CountSelectedItems().
Sourcepub fn is_item_selected(&self, index: usize) -> bool
pub fn is_item_selected(&self, index: usize) -> bool
Returns true if the option at the given index is selected.
Sourcepub fn selected_index(&self, sel_index: usize) -> Option<usize>
pub fn selected_index(&self, sel_index: usize) -> Option<usize>
Returns the selected option index at position sel_index within the selection list.
Corresponds to upstream CPDF_FormField::GetSelectedIndex().
Sourcepub fn get_selected_index(&self, sel_index: usize) -> Option<usize>
pub fn get_selected_index(&self, sel_index: usize) -> Option<usize>
Upstream-aligned alias for selected_index().
Corresponds to upstream CPDF_FormField::GetSelectedIndex().
Sourcepub fn clear_selection(&mut self) -> Result<(), DocError>
pub fn clear_selection(&mut self) -> Result<(), DocError>
Clear the selection for a choice field.
Clears the in-memory selected indices list. To persist the change to a
PDF file, use EditableForm::clear_field_selection in rpdfium-edit.
Sourcepub fn set_read_only(&mut self, v: bool)
pub fn set_read_only(&mut self, v: bool)
Set or clear the read-only flag for this field.
Updates the in-memory flags. To persist the change to a PDF file,
use EditableForm::set_field_read_only in rpdfium-edit.
Sourcepub fn set_required(&mut self, v: bool)
pub fn set_required(&mut self, v: bool)
Set or clear the required flag for this field.
Updates the in-memory flags. To persist the change to a PDF file,
use EditableForm::set_field_required in rpdfium-edit.
Sourcepub fn set_no_export(&mut self, v: bool)
pub fn set_no_export(&mut self, v: bool)
Set or clear the no-export flag for this field.
Updates the in-memory flags. To persist the change to a PDF file,
use EditableForm::set_field_no_export in rpdfium-edit.
Sourcepub fn additional_actions(&self) -> Option<&AdditionalActions>
pub fn additional_actions(&self) -> Option<&AdditionalActions>
Returns the additional actions for this field, if any.
Sourcepub fn get_additional_actions(&self) -> Option<&AdditionalActions>
pub fn get_additional_actions(&self) -> Option<&AdditionalActions>
ADR-019 alias for additional_actions().
Corresponds to CPDF_FormField::GetAdditionalAction() in PDFium.
Sourcepub fn option_count(&self) -> usize
pub fn option_count(&self) -> usize
Returns the number of options for choice fields.
Corresponds to upstream CPDF_FormField::CountOptions().
Sourcepub fn count_options(&self) -> usize
pub fn count_options(&self) -> usize
Upstream-aligned alias for option_count().
Corresponds to upstream CPDF_FormField::CountOptions().
Sourcepub fn option_label(&self, index: usize) -> Option<&str>
pub fn option_label(&self, index: usize) -> Option<&str>
Returns the display label of the option at index, or None if out of bounds.
Corresponds to upstream CPDF_FormField::GetOptionLabel(index).
Sourcepub fn get_option_label(&self, index: usize) -> Option<&str>
pub fn get_option_label(&self, index: usize) -> Option<&str>
Upstream-aligned alias for option_label().
Corresponds to upstream CPDF_FormField::GetOptionLabel(index).
Sourcepub fn option_value(&self, index: usize) -> Option<&str>
pub fn option_value(&self, index: usize) -> Option<&str>
Returns the export value of the option at index, or None if out of bounds.
Corresponds to upstream CPDF_FormField::GetOptionValue(index).
Sourcepub fn get_option_value(&self, index: usize) -> Option<&str>
pub fn get_option_value(&self, index: usize) -> Option<&str>
Upstream-aligned alias for option_value().
Corresponds to upstream CPDF_FormField::GetOptionValue(index).
Sourcepub fn control_count(&self) -> usize
pub fn control_count(&self) -> usize
Returns the number of widget controls for this field.
Corresponds to upstream CPDF_FormField::CountControls().
Sourcepub fn count_controls(&self) -> usize
pub fn count_controls(&self) -> usize
Upstream-aligned alias for control_count().
Corresponds to upstream CPDF_FormField::CountControls().
Sourcepub fn control_at(&self, index: usize) -> Option<&FormControl>
pub fn control_at(&self, index: usize) -> Option<&FormControl>
Returns the control at index, or None if out of bounds.
Corresponds to upstream CPDF_FormField::GetControl(index).
Sourcepub fn get_control(&self, index: usize) -> Option<&FormControl>
pub fn get_control(&self, index: usize) -> Option<&FormControl>
Upstream-aligned alias for control_at().
Corresponds to upstream CPDF_FormField::GetControl(index).