pub struct InkAnnotationBuilder { /* private fields */ }Expand description
Builder for ink annotations. Accumulates strokes (each stroke is a polyline
of (x, y) points in page space, origin bottom-left) and produces a PDF
annotation dictionary plus its appearance stream.
Implementations§
Source§impl InkAnnotationBuilder
impl InkAnnotationBuilder
Sourcepub fn add_stroke(&mut self, points: Vec<(f64, f64)>)
pub fn add_stroke(&mut self, points: Vec<(f64, f64)>)
Add a stroke (a polyline of (x, y) points in page space, origin
bottom-left, Y+ upward). Each point is in PDF user-space units (1/72 inch).
At least two points are needed to form a line; single-point or empty
strokes are silently dropped.
Sourcepub fn set_color(&mut self, r: f64, g: f64, b: f64)
pub fn set_color(&mut self, r: f64, g: f64, b: f64)
Set the stroke color (DeviceRGB). Each component is in the range [0.0, 1.0].
Sourcepub fn compute_rect(&self) -> Option<Rect>
pub fn compute_rect(&self) -> Option<Rect>
Compute the bounding rectangle from all strokes, with a small margin to
account for the line width. Returns None if there are no strokes.
Sourcepub fn build(&self) -> Option<(InkAnnotDict, Vec<u8>)>
pub fn build(&self) -> Option<(InkAnnotDict, Vec<u8>)>
Build the annotation dictionary and appearance stream. Returns:
- A PDF dictionary (the annotation object’s content, as key-value pairs)
- The appearance stream bytes (a PDF content stream for
/AP /N)
Returns None if there are no strokes (nothing to serialize).
The caller is responsible for:
- Wrapping the dict in an indirect object (e.g.,
5 0 obj <dict> endobj) - Wrapping the appearance bytes in a stream object with the correct header
- Assigning object numbers and wiring
/AP /Nto reference the stream
Trait Implementations§
Source§impl Clone for InkAnnotationBuilder
impl Clone for InkAnnotationBuilder
Source§fn clone(&self) -> InkAnnotationBuilder
fn clone(&self) -> InkAnnotationBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more