pub struct AnnotList {
pub annots: Vec<Annotation>,
pub source_indices: Vec<usize>,
pub popups: Vec<(usize, Annotation)>,
}Expand description
A page’s annotations as the rendering path sees them.
use pdfrum_doc::annot::AnnotList;
use pdfrum_object::{Array, Dict, Name, NoResolve, Object, PdfString};
let note = Dict::from_pairs([
(Name::from("Subtype"), Object::Name(Name::from("Text"))),
(Name::from("Contents"), Object::Str(PdfString::literal(b"a note"))),
(
Name::from("Rect"),
Object::Array(Array::of([10, 300, 30, 320])),
),
]);
let page = Dict::from_pairs([(
Name::from("Annots"),
Object::Array(Array::of([Object::Dict(note)])),
)]);
// `page_width` is the crop-box width, which decides where a
// synthesized pop-up lands.
let list = AnnotList::load(&page, 612.0, &NoResolve);
assert_eq!(list.annots.len(), 1);
// The file declares no pop-up; one is synthesized for the note.
assert_eq!(list.popups.len(), 1);Fields§
§annots: Vec<Annotation>The annotations the file declares, minus its pop-ups, in /Annots
order.
source_indices: Vec<usize>Their indices in the original /Annots array, which the dump and the
overlay are keyed by.
popups: Vec<(usize, Annotation)>Pop-ups synthesized for the annotations above, appended after them.
Each records which entry of annots it belongs to.
Implementations§
Source§impl AnnotList
impl AnnotList
Sourcepub fn load<R: Resolve>(page: &Dict, page_width: f32, r: &R) -> AnnotList
pub fn load<R: Resolve>(page: &Dict, page_width: f32, r: &R) -> AnnotList
Builds the list for one page.
page_width is the crop-box width, which decides where a synthesized
pop-up lands.
use pdfrum_doc::annot::AnnotList;
use pdfrum_object::{Array, Dict, Name, NoResolve, Object, PdfString};
let note = Dict::from_pairs([
(Name::from("Subtype"), Object::Name(Name::from("Text"))),
(Name::from("Contents"), Object::Str(PdfString::literal(b"a note"))),
(
Name::from("Rect"),
Object::Array(Array::of([10, 300, 30, 320])),
),
]);
let page = Dict::from_pairs([(
Name::from("Annots"),
Object::Array(Array::of([Object::Dict(note)])),
)]);
// `page_width` is the crop-box width, which decides where a
// synthesized pop-up lands.
let list = AnnotList::load(&page, 612.0, &NoResolve);
// The index in the original `/Annots` array survives, which is what
// keeps the dump and the appearance overlay aligned.
assert_eq!(list.source_indices, [0]);Trait Implementations§
impl StructuralPartialEq for AnnotList
Auto Trait Implementations§
impl Freeze for AnnotList
impl RefUnwindSafe for AnnotList
impl Send for AnnotList
impl Sync for AnnotList
impl Unpin for AnnotList
impl UnsafeUnpin for AnnotList
impl UnwindSafe for AnnotList
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more