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

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