Skip to main content

update_annotation

Function update_annotation 

Source
pub fn update_annotation(
    edit: &mut EditDoc<'_>,
    page: impl Into<PageIndex>,
    annot: ObjRef,
    write: impl Into<AnnotWrite>,
) -> Result<(), Error>
Expand description

Replaces an existing annotation object in place, regenerating /AP when the subtype has an appearance generator.

The object number is preserved. annot must already appear in page’s /Annots.

use pdfrum_edit::{TextSpec, add_annotation, update_annotation};
use pdfrum_edit::EditDoc;
use kurbo::Rect;
use peniko::Color;
let rect = Rect::new(10.0, 10.0, 40.0, 40.0);
let r = add_annotation(&mut edit, 0, TextSpec::new(rect, Color::from_rgb8(255, 200, 0)))?;
update_annotation(
    &mut edit,
    0,
    r,
    TextSpec::new(rect, Color::from_rgb8(255, 200, 0)).contents("updated"),
)?;

§Errors