Struct pdfium_render::form::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> !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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.