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