pub struct Annotation {
pub annotation_type: AnnotationType,
pub rect: Rectangle,
pub contents: Option<String>,
pub subject: Option<String>,
pub name: Option<String>,
pub modified: Option<String>,
pub flags: AnnotationFlags,
pub border: Option<BorderStyle>,
pub color: Option<Color>,
pub page: Option<ObjectReference>,
pub properties: Dictionary,
/* private fields */
}Expand description
Base annotation structure
Fields§
§annotation_type: AnnotationTypeAnnotation type
rect: RectangleRectangle defining annotation position
contents: Option<String>Optional content text
subject: Option<String>Optional subject
name: Option<String>Optional annotation name
modified: Option<String>Modification date
flags: AnnotationFlagsFlags
border: Option<BorderStyle>Border style
color: Option<Color>Color
page: Option<ObjectReference>Page reference (set by manager)
properties: DictionaryAdditional properties specific to annotation type
Implementations§
Source§impl Annotation
impl Annotation
Sourcepub fn new(annotation_type: AnnotationType, rect: Rectangle) -> Self
pub fn new(annotation_type: AnnotationType, rect: Rectangle) -> Self
Create a new annotation
Sourcepub fn with_contents(self, contents: impl Into<String>) -> Self
pub fn with_contents(self, contents: impl Into<String>) -> Self
Set contents
Sourcepub fn with_subject(self, subject: impl Into<String>) -> Self
pub fn with_subject(self, subject: impl Into<String>) -> Self
Set subject
Sourcepub fn with_color(self, color: Color) -> Self
pub fn with_color(self, color: Color) -> Self
Set color
Sourcepub fn with_border(self, border: BorderStyle) -> Self
pub fn with_border(self, border: BorderStyle) -> Self
Set border
Sourcepub fn with_flags(self, flags: AnnotationFlags) -> Self
pub fn with_flags(self, flags: AnnotationFlags) -> Self
Set flags
Sourcepub fn set_field_dict(&mut self, field_dict: Dictionary)
pub fn set_field_dict(&mut self, field_dict: Dictionary)
Set field dictionary properties (for widget annotations)
Sourcepub fn set_field_parent(&mut self, parent: ObjectReference)
pub fn set_field_parent(&mut self, parent: ObjectReference)
Set the parent form-field reference for a Widget annotation.
Widget annotations that live as children of an /AcroForm field
(ISO 32000-1 §12.7.3.1) must carry /Parent pointing at the
parent field dictionary. This setter records that relationship;
the writer remaps the placeholder to a real indirect-object id
at serialization time.
Only meaningful for AnnotationType::Widget.
§Panics
In debug builds, calling this on a non-Widget annotation
trips a debug_assert! — using /Parent on a non-Widget
annotation is a spec violation and almost always a programmer
error. In release builds the setter still stores the value
(no panic), but the defence-in-depth check in to_dict will
refuse to emit /Parent for non-Widget annotations, so a
mis-targeted call is degraded to a silent no-op rather than an
invalid PDF.
Sourcepub fn to_dict(&self) -> Dictionary
pub fn to_dict(&self) -> Dictionary
Convert to PDF dictionary
Trait Implementations§
Source§impl Clone for Annotation
impl Clone for Annotation
Source§fn clone(&self) -> Annotation
fn clone(&self) -> Annotation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more