Skip to main content

FormField

Struct FormField 

Source
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: String

Fully qualified field name (parent.child format).

§field_type: FormFieldType

Field type.

§value: Option<String>

Current value (/V).

§default_value: Option<String>

Default value (/DV).

§flags: FormFieldFlags

Field 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: bool

Whether 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

Source

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. Bool on a Text field).
  • A text value exceeds /MaxLen.
  • A choice index is out of range.
Source

pub fn controls(&self) -> &[FormControl]

Returns the widget controls associated with this field.

Source

pub fn needs_appearance(&self) -> bool

Returns true if the field has been modified and its appearance stream needs regeneration.

Source

pub fn reset_to_default(&mut self)

Reset the field to its default value (/DV), or clear if none.

Source

pub fn selected_item_count(&self) -> usize

Returns the number of currently selected items.

Corresponds to upstream CPDF_FormField::CountSelectedItems().

Source

pub fn count_selected_items(&self) -> usize

Upstream-aligned alias for selected_item_count().

Corresponds to upstream CPDF_FormField::CountSelectedItems().

Source

pub fn is_item_selected(&self, index: usize) -> bool

Returns true if the option at the given index is selected.

Source

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().

Source

pub fn get_selected_index(&self, sel_index: usize) -> Option<usize>

Upstream-aligned alias for selected_index().

Corresponds to upstream CPDF_FormField::GetSelectedIndex().

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn additional_actions(&self) -> Option<&AdditionalActions>

Returns the additional actions for this field, if any.

Source

pub fn get_additional_actions(&self) -> Option<&AdditionalActions>

ADR-019 alias for additional_actions().

Corresponds to CPDF_FormField::GetAdditionalAction() in PDFium.

Source

pub fn option_count(&self) -> usize

Returns the number of options for choice fields.

Corresponds to upstream CPDF_FormField::CountOptions().

Source

pub fn count_options(&self) -> usize

Upstream-aligned alias for option_count().

Corresponds to upstream CPDF_FormField::CountOptions().

Source

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).

Source

pub fn get_option_label(&self, index: usize) -> Option<&str>

Upstream-aligned alias for option_label().

Corresponds to upstream CPDF_FormField::GetOptionLabel(index).

Source

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).

Source

pub fn get_option_value(&self, index: usize) -> Option<&str>

Upstream-aligned alias for option_value().

Corresponds to upstream CPDF_FormField::GetOptionValue(index).

Source

pub fn control_count(&self) -> usize

Returns the number of widget controls for this field.

Corresponds to upstream CPDF_FormField::CountControls().

Source

pub fn count_controls(&self) -> usize

Upstream-aligned alias for control_count().

Corresponds to upstream CPDF_FormField::CountControls().

Source

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).

Source

pub fn get_control(&self, index: usize) -> Option<&FormControl>

Upstream-aligned alias for control_at().

Corresponds to upstream CPDF_FormField::GetControl(index).

Trait Implementations§

Source§

impl Clone for FormField

Source§

fn clone(&self) -> FormField

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FormField

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more