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