pdf/src/read/object.rs#
Source: lib/pdf/src/read/object.rs
The objects of a PDF file as the reader gives them (ISO 32000-1, 7.3): null, booleans,
integers, reals, strings (bytes; text strings are decoded by text_string), names, arrays,
dictionaries, streams and references to indirect objects. A stream holds its dictionary and
where its data lies in the file; Document::decode gives the data with the filters applied.
struct Refa reference to an indirect object: its number and generationnum: u32generation: u16
struct Name(pub Vec<u8>)a name (/Type): its bytes with #xx escapes resolved
impl Name
fn as_bytes(&self) -> &[u8]fn to_text(&self) -> Stringthe name as text (bytes that are not UTF-8 become U+FFFD)struct Dict(pub(crate) Arc<BTreeMap<Name, Object>>)a dictionary; a key given twice keeps its last value. Copies share their entries until one of them changes (inherited resources, the pages of a tree and the caches of drawing copy dictionaries freely; a hostile file must not turn that into memory without end)
impl Dict
fn new() -> Dictfn get(&self, key: &str) -> Option<&Object>the value of a key (without the slash: "Type")fn get_bytes(&self, key: &[u8]) -> Option<&Object>fn contains(&self, key: &str) -> boolfn insert(&mut self, key: &str, value: Object)fn remove(&mut self, key: &str) -> Option<Object>the value of a key, taken outfn len(&self) -> usizefn is_empty(&self) -> boolfn iter(&self) -> impl Iterator<Item = (&Name, &Object)>fn name(&self, key: &str) -> Option<&[u8]>the name under a key (Type, Subtype, ...), if it is onefn is(&self, key: &str, v: &str) -> boola key whose value is the namevfn int(&self, key: &str) -> Option<i64>fn num(&self, key: &str) -> Option<f64>struct Streama stream: its dictionary, and where its (still encoded) data lies in the filedict: Dict
impl Stream
fn raw_len(&self) -> usizethe number of encoded bytesenum Objectone object of a PDF fileNullBool(bool)Int(i64)Real(f64)String(Vec<u8>)-- a string's bytes (decrypted); text strings decode with text_stringName(Name)Array(Vec<Object>)Dict(Dict)Stream(alloc::boxed::Box<Stream>)-- boxed: keeps every object at 32 bytesRef(Ref)
impl Object
fn name(s: &str) -> Objectfn is_null(&self) -> boolfn as_bool(&self) -> Option<bool>fn as_int(&self) -> Option<i64>an integer, or a real that is one (some writers put 1.0 where an integer belongs)fn as_f64(&self) -> Option<f64>a numberfn as_name(&self) -> Option<&[u8]>fn as_bytes(&self) -> Option<&[u8]>a string's bytesfn as_array(&self) -> Option<&[Object]>fn as_dict(&self) -> Option<&Dict>a dictionary, or a stream's dictionaryfn as_stream(&self) -> Option<&Stream>fn as_ref(&self) -> Option<Ref>fn as_rect(&self) -> Option<[f64; 4]>a rectangle [x0 y0 x1 y1], normalized so that x0 <= x1 and y0 <= y1fn text_string(b: &[u8]) -> Stringa text string (7.9.2.2) as text: UTF-16BE after FE FF, UTF-16LE after FF FE (seen in the wild), UTF-8 after EF BB BF (PDF 2.0), else PDFDocEncoding