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>
impl<'a> PdfForm<'a>
Sourcepub fn bindings(&self) -> &'a dyn PdfiumLibraryBindings
pub fn bindings(&self) -> &'a dyn PdfiumLibraryBindings
Returns the PdfiumLibraryBindings used by this PdfForm.
Sourcepub fn form_type(&self) -> PdfFormType
pub fn form_type(&self) -> PdfFormType
Returns the PdfFormType of this PdfForm.
Sourcepub fn field_values(
&self,
pages: &'a PdfPages<'a>,
) -> HashMap<String, Option<String>>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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