pub struct PdfDictionary(pub HashMap<PdfName, PdfObject>);Expand description
PDF Dictionary object - Key-value mapping with name keys.
Dictionaries are the primary way to represent complex data structures in PDF. Keys must be PdfName objects, values can be any PDF object type.
§Common Dictionary Types
- Catalog: Document root (
/Type /Catalog) - Page: Individual page (
/Type /Page) - Font: Font definition (
/Type /Font) - Stream: Binary data with metadata
§Example
use oxidize_pdf::parser::objects::{PdfDictionary, PdfObject, PdfName};
let mut page_dict = PdfDictionary::new();
page_dict.insert("Type".to_string(),
PdfObject::Name(PdfName::new("Page".to_string())));
page_dict.insert("Parent".to_string(),
PdfObject::Reference(2, 0)); // Reference to pages tree
// Access values
assert_eq!(page_dict.get_type(), Some("Page"));
assert!(page_dict.contains_key("Parent"));Tuple Fields§
§0: HashMap<PdfName, PdfObject>Implementations§
Source§impl PdfDictionary
impl PdfDictionary
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new empty dictionary.
§Example
use oxidize_pdf::parser::objects::{PdfDictionary, PdfObject, PdfName};
let mut dict = PdfDictionary::new();
dict.insert("Type".to_string(), PdfObject::Name(PdfName::new("Font".to_string())));Sourcepub fn get(&self, key: &str) -> Option<&PdfObject>
pub fn get(&self, key: &str) -> Option<&PdfObject>
Get a value by key name.
§Arguments
key- The key name (without leading slash)
§Returns
Reference to the value if the key exists, None otherwise.
§Example
use oxidize_pdf::parser::objects::{PdfDictionary, PdfObject};
let mut dict = PdfDictionary::new();
dict.insert("Length".to_string(), PdfObject::Integer(1000));
if let Some(length) = dict.get("Length").and_then(|o| o.as_integer()) {
println!("Stream length: {}", length);
}Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Check if dictionary contains a key
Sourcepub fn get_type(&self) -> Option<&str>
pub fn get_type(&self) -> Option<&str>
Get the dictionary type (value of /Type key).
Many PDF dictionaries have a /Type entry that identifies their purpose.
§Returns
The type name if present, None otherwise.
§Common Types
- “Catalog” - Document catalog
- “Page” - Page object
- “Pages” - Page tree node
- “Font” - Font dictionary
- “XObject” - External object
§Example
use oxidize_pdf::parser::objects::{PdfDictionary, PdfObject, PdfName};
let mut dict = PdfDictionary::new();
dict.insert("Type".to_string(), PdfObject::Name(PdfName::new("Page".to_string())));
assert_eq!(dict.get_type(), Some("Page"));Trait Implementations§
Source§impl Clone for PdfDictionary
impl Clone for PdfDictionary
Source§fn clone(&self) -> PdfDictionary
fn clone(&self) -> PdfDictionary
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PdfDictionary
impl Debug for PdfDictionary
Source§impl Default for PdfDictionary
impl Default for PdfDictionary
Source§impl PartialEq for PdfDictionary
impl PartialEq for PdfDictionary
impl StructuralPartialEq for PdfDictionary
Auto Trait Implementations§
impl Freeze for PdfDictionary
impl RefUnwindSafe for PdfDictionary
impl Send for PdfDictionary
impl Sync for PdfDictionary
impl Unpin for PdfDictionary
impl UnwindSafe for PdfDictionary
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().