Skip to main content

annot_ap

Function annot_ap 

Source
pub fn annot_ap<R: Resolve>(
    dict: &Dict,
    mode: ApMode,
    fallback_to_normal: bool,
    r: &R,
) -> Option<Stream>
Expand description

Resolves an annotation’s appearance stream.

fallback_to_normal decides what a missing rollover or down entry means. With it set, a missing key falls back to /N; a key that is present but holds nothing usable does not — it suppresses the fallback and the lookup comes back empty.

use pdfrum_doc::annot::{ApMode, annot_ap, has_appearance};
use pdfrum_object::{ByteSpan, Dict, Name, NoResolve, Object, Stream};

let normal = Stream::new(Dict::default(), ByteSpan::whole(b"0 0 10 10 re f".as_slice().into()));
let annot = Dict::from_pairs([(
    Name::from("AP"),
    Object::Dict(Dict::from_pairs([(
        Name::from("N"),
        Object::Stream(Box::new(normal)),
    )])),
)]);

assert!(annot_ap(&annot, ApMode::Normal, false, &NoResolve).is_some());
// No `/AP` at all: nothing.
assert!(annot_ap(&Dict::default(), ApMode::Normal, true, &NoResolve).is_none());