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

1//! Defines the [PdfFormPushButtonField] struct, exposing functionality related to a single
2//! form field of type `PdfFormFieldType::PushButton`.
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::PushButton`. The form field object defines
9/// an interactive button widget that can be clicked or tapped by the user.
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 PdfFormPushButtonField<'a> {
16    form_handle: FPDF_FORMHANDLE,
17    annotation_handle: FPDF_ANNOTATION,
18    bindings: &'a dyn PdfiumLibraryBindings,
19}
20
21impl<'a> PdfFormPushButtonField<'a> {
22    #[inline]
23    pub(crate) fn from_pdfium(
24        form_handle: FPDF_FORMHANDLE,
25        annotation_handle: FPDF_ANNOTATION,
26        bindings: &'a dyn PdfiumLibraryBindings,
27    ) -> Self {
28        PdfFormPushButtonField {
29            form_handle,
30            annotation_handle,
31            bindings,
32        }
33    }
34
35    /// Returns the [PdfiumLibraryBindings] used by this [PdfFormPushButtonField] object.
36    #[inline]
37    pub fn bindings(&self) -> &'a dyn PdfiumLibraryBindings {
38        self.bindings
39    }
40}
41
42impl<'a> PdfFormFieldPrivate<'a> for PdfFormPushButtonField<'a> {
43    #[inline]
44    fn form_handle(&self) -> &FPDF_FORMHANDLE {
45        &self.form_handle
46    }
47
48    #[inline]
49    fn annotation_handle(&self) -> &FPDF_ANNOTATION {
50        &self.annotation_handle
51    }
52
53    #[inline]
54    fn bindings(&self) -> &dyn PdfiumLibraryBindings {
55        self.bindings
56    }
57}