pdfium_render/pdf/document/page/annotation/
stamp.rs

1//! Defines the [PdfPageStampAnnotation] struct, exposing functionality related to a single
2//! user annotation of type `PdfPageAnnotationType::Stamp`.
3
4use crate::bindgen::{FPDF_ANNOTATION, FPDF_DOCUMENT, FPDF_PAGE};
5use crate::bindings::PdfiumLibraryBindings;
6use crate::pdf::document::page::annotation::attachment_points::PdfPageAnnotationAttachmentPoints;
7use crate::pdf::document::page::annotation::objects::PdfPageAnnotationObjects;
8use crate::pdf::document::page::annotation::private::internal::PdfPageAnnotationPrivate;
9
10/// A single `PdfPageAnnotation` of type `PdfPageAnnotationType::Stamp`.
11pub struct PdfPageStampAnnotation<'a> {
12    handle: FPDF_ANNOTATION,
13    objects: PdfPageAnnotationObjects<'a>,
14    attachment_points: PdfPageAnnotationAttachmentPoints<'a>,
15    bindings: &'a dyn PdfiumLibraryBindings,
16}
17
18impl<'a> PdfPageStampAnnotation<'a> {
19    pub(crate) fn from_pdfium(
20        document_handle: FPDF_DOCUMENT,
21        page_handle: FPDF_PAGE,
22        annotation_handle: FPDF_ANNOTATION,
23        bindings: &'a dyn PdfiumLibraryBindings,
24    ) -> Self {
25        PdfPageStampAnnotation {
26            handle: annotation_handle,
27            objects: PdfPageAnnotationObjects::from_pdfium(
28                document_handle,
29                page_handle,
30                annotation_handle,
31                bindings,
32            ),
33            attachment_points: PdfPageAnnotationAttachmentPoints::from_pdfium(
34                annotation_handle,
35                bindings,
36            ),
37            bindings,
38        }
39    }
40
41    /// Returns a mutable collection of all the page objects in this [PdfPageStampAnnotation].
42    #[inline]
43    pub fn objects_mut(&mut self) -> &mut PdfPageAnnotationObjects<'a> {
44        &mut self.objects
45    }
46}
47
48impl<'a> PdfPageAnnotationPrivate<'a> for PdfPageStampAnnotation<'a> {
49    #[inline]
50    fn handle(&self) -> FPDF_ANNOTATION {
51        self.handle
52    }
53
54    #[inline]
55    fn bindings(&self) -> &dyn PdfiumLibraryBindings {
56        self.bindings
57    }
58
59    #[inline]
60    fn objects_impl(&self) -> &PdfPageAnnotationObjects {
61        &self.objects
62    }
63
64    #[inline]
65    fn objects_mut_impl(&mut self) -> &mut PdfPageAnnotationObjects<'a> {
66        self.objects_mut()
67    }
68
69    #[inline]
70    fn attachment_points_impl(&self) -> &PdfPageAnnotationAttachmentPoints {
71        &self.attachment_points
72    }
73
74    #[inline]
75    fn attachment_points_mut_impl(&mut self) -> &mut PdfPageAnnotationAttachmentPoints<'a> {
76        &mut self.attachment_points
77    }
78}