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/// A single `PdfFormField` of type `PdfFormFieldType::Unknown`.
9///
10/// Form fields in Pdfium are wrapped inside page annotations of type `PdfPageAnnotationType::Widget`
11/// or `PdfPageAnnotationType::XfaWidget`. User-specified values can be retrieved directly from
12/// each form field object by unwrapping the form field from the annotation, or in bulk from the
13/// `PdfForm::field_values()` function.
14pub struct PdfFormUnknownField<'a> {
15    form_handle: FPDF_FORMHANDLE,
16    annotation_handle: FPDF_ANNOTATION,
17    bindings: &'a dyn PdfiumLibraryBindings,
18}
19
20impl<'a> PdfFormUnknownField<'a> {
21    pub(crate) fn from_pdfium(
22        form_handle: FPDF_FORMHANDLE,
23        annotation_handle: FPDF_ANNOTATION,
24        bindings: &'a dyn PdfiumLibraryBindings,
25    ) -> Self {
26        PdfFormUnknownField {
27            form_handle,
28            annotation_handle,
29            bindings,
30        }
31    }
32
33    /// Returns the [PdfiumLibraryBindings] used by this [PdfFormUnknownField] object.
34    #[inline]
35    pub fn bindings(&self) -> &'a dyn PdfiumLibraryBindings {
36        self.bindings
37    }
38}
39
40impl<'a> PdfFormFieldPrivate<'a> for PdfFormUnknownField<'a> {
41    #[inline]
42    fn form_handle(&self) -> &FPDF_FORMHANDLE {
43        &self.form_handle
44    }
45
46    #[inline]
47    fn annotation_handle(&self) -> &FPDF_ANNOTATION {
48        &self.annotation_handle
49    }
50
51    #[inline]
52    fn bindings(&self) -> &dyn PdfiumLibraryBindings {
53        self.bindings
54    }
55}