PdfForm

Struct PdfForm 

Source
pub struct PdfForm<'a> { /* private fields */ }
Expand description

The PdfForm embedded inside a PdfDocument.

Form fields in Pdfium are exposed as page annotations of type PdfPageAnnotationType::Widget or PdfPageAnnotationType::XfaWidget, depending on the type of form embedded inside the document. To retrieve the user-specified form field values, iterate over each annotation on each page in the document, filtering out annotations that do not contain a valid form field:

for page in document.pages.iter() {
    for annotation in page.annotations.iter() {
        if let Some(field) = annotation.as_form_field() {
            // We can now unwrap the specific type of form field
            // and access its properties, including any user-specified value.
        }
    }
}

Alternatively, use the PdfForm::field_values() function to eagerly retrieve the values of all fields in the document as a map of (field name, field value) pairs.

Implementations§

Source§

impl<'a> PdfForm<'a>

Source

pub fn bindings(&self) -> &'a dyn PdfiumLibraryBindings

Returns the PdfiumLibraryBindings used by this PdfForm.

Source

pub fn form_type(&self) -> PdfFormType

Returns the PdfFormType of this PdfForm.

Source

pub fn field_values( &self, pages: &'a PdfPages<'a>, ) -> HashMap<String, Option<String>>

Captures a string representation of the value of every form field on every page of the given PdfPages collection, returning a map of (field name, field value) pairs.

This function assumes that all form fields in the document have unique field names except for radio button and checkbox control groups.

Trait Implementations§

Source§

impl<'a> Drop for PdfForm<'a>

Source§

fn drop(&mut self)

Closes this PdfForm, releasing held memory.

Auto Trait Implementations§

§

impl<'a> Freeze for PdfForm<'a>

§

impl<'a> !RefUnwindSafe for PdfForm<'a>

§

impl<'a> !Send for PdfForm<'a>

§

impl<'a> !Sync for PdfForm<'a>

§

impl<'a> Unpin for PdfForm<'a>

§

impl<'a> !UnwindSafe for PdfForm<'a>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.