[][src]Struct pdf_forms::Form

pub struct Form {
    pub document: Document,
    // some fields omitted
}

A PDF Form that contains fillable fields

Use this struct to load an existing PDF with a fillable form using the load method. It will analyze the PDF and identify the fields. Then you can get and set the content of the fields by index.

Fields

document: Document

Implementations

impl Form[src]

pub fn load_from<R: Read>(reader: R) -> Result<Self, LoadError>[src]

Takes a reader containing a PDF with a fillable form, analyzes the content, and attempts to identify all of the fields the form has.

pub fn load<P: AsRef<Path>>(path: P) -> Result<Self, LoadError>[src]

Takes a path to a PDF with a fillable form, analyzes the file, and attempts to identify all of the fields the form has.

pub fn len(&self) -> usize[src]

Returns the number of fields the form has

pub fn is_empty(&self) -> bool[src]

Returns true if empty

pub fn get_type(&self, n: usize) -> FieldType[src]

Gets the type of field of the given index

Panics

This function will panic if the index is greater than the number of fields

pub fn get_name(&self, n: usize) -> Option<String>[src]

Gets the name of field of the given index

Panics

This function will panic if the index is greater than the number of fields

pub fn get_all_types(&self) -> Vec<FieldType>[src]

Gets the types of all of the fields in the form

pub fn get_all_names(&self) -> Vec<Option<String>>[src]

Gets the names of all of the fields in the form

pub fn get_state(&self, n: usize) -> FieldState[src]

Gets the state of field of the given index

Panics

This function will panic if the index is greater than the number of fields

pub fn get_object_id(&self, n: usize) -> ObjectId[src]

Gets the object of field of the given index

Panics

Will panic if n is larger than the number of fields

pub fn set_text(&mut self, n: usize, s: String) -> Result<(), ValueError>[src]

If the field at index n is a text field, fills in that field with the text s. If it is not a text field, returns ValueError

Panics

Will panic if n is larger than the number of fields

pub fn set_check_box(
    &mut self,
    n: usize,
    is_checked: bool
) -> Result<(), ValueError>
[src]

If the field at index n is a checkbox field, toggles the check box based on the value is_checked. If it is not a checkbox field, returns ValueError

Panics

Will panic if n is larger than the number of fields

pub fn set_radio(&mut self, n: usize, choice: String) -> Result<(), ValueError>[src]

If the field at index n is a radio field, toggles the radio button based on the value choice If it is not a radio button field or the choice is not a valid option, returns ValueError

Panics

Will panic if n is larger than the number of fields

pub fn set_list_box(
    &mut self,
    n: usize,
    choices: Vec<String>
) -> Result<(), ValueError>
[src]

If the field at index n is a listbox field, selects the options in choice If it is not a listbox field or one of the choices is not a valid option, or if too many choices are selected, returns ValueError

Panics

Will panic if n is larger than the number of fields

pub fn set_combo_box(
    &mut self,
    n: usize,
    choice: String
) -> Result<(), ValueError>
[src]

If the field at index n is a combobox field, selects the options in choice If it is not a combobox field or one of the choices is not a valid option, or if too many choices are selected, returns ValueError

Panics

Will panic if n is larger than the number of fields

pub fn remove_field(&mut self, n: usize) -> Result<(), ValueError>[src]

Removes the field at index n

Panics

Will panic if n is larger than the number of fields

pub fn save<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error>[src]

Saves the form to the specified path

pub fn save_to<W: Write>(&mut self, target: &mut W) -> Result<(), Error>[src]

Saves the form to the specified path

Auto Trait Implementations

impl RefUnwindSafe for Form

impl Send for Form

impl Sync for Form

impl Unpin for Form

impl UnwindSafe for Form

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.