pdfium_render/pdf/document/page/field/
unknown.rs

1//! Defines the [PdfFormUnknownField] struct, exposing functionality related to a single
2//! form field of type [PdfFormFieldType::Unknown].
3//!
4use crate::bindgen::{FPDF_ANNOTATION, FPDF_FORMHANDLE};
5use crate::bindings::PdfiumLibraryBindings;
6use crate::pdf::document::page::field::private::internal::PdfFormFieldPrivate;
7
8#[cfg(doc)]
9use {
10    crate::pdf::document::form::PdfForm,
11    crate::pdf::document::page::annotation::PdfPageAnnotationType,
12    crate::pdf::document::page::field::{PdfFormField, PdfFormFieldType},
13};
14
15/// A single [PdfFormField] of type [PdfFormFieldType::Unknown].
16///
17/// Form fields in Pdfium are wrapped inside page annotations of type [PdfPageAnnotationType::Widget]
18/// or [PdfPageAnnotationType::XfaWidget]. User-specified values can be retrieved directly from
19/// each form field object by unwrapping the form field from the annotation, or in bulk from the
20/// [PdfForm::field_values()] function.
21pub struct PdfFormUnknownField<'a> {
22    form_handle: FPDF_FORMHANDLE,
23    annotation_handle: FPDF_ANNOTATION,
24    bindings: &'a dyn PdfiumLibraryBindings,
25}
26
27impl<'a> PdfFormUnknownField<'a> {
28    pub(crate) fn from_pdfium(
29        form_handle: FPDF_FORMHANDLE,
30        annotation_handle: FPDF_ANNOTATION,
31        bindings: &'a dyn PdfiumLibraryBindings,
32    ) -> Self {
33        PdfFormUnknownField {
34            form_handle,
35            annotation_handle,
36            bindings,
37        }
38    }
39
40    /// Returns the [PdfiumLibraryBindings] used by this [PdfFormUnknownField] object.
41    #[inline]
42    pub fn bindings(&self) -> &'a dyn PdfiumLibraryBindings {
43        self.bindings
44    }
45}
46
47impl<'a> PdfFormFieldPrivate<'a> for PdfFormUnknownField<'a> {
48    #[inline]
49    fn form_handle(&self) -> FPDF_FORMHANDLE {
50        self.form_handle
51    }
52
53    #[inline]
54    fn annotation_handle(&self) -> FPDF_ANNOTATION {
55        self.annotation_handle
56    }
57
58    #[inline]
59    fn bindings(&self) -> &dyn PdfiumLibraryBindings {
60        self.bindings
61    }
62}