Skip to main content

PdfObject

Enum PdfObject 

Source
pub enum PdfObject {
    Null,
    Bool(bool),
    Integer(i64),
    Real(f64),
    Name(Vec<u8>),
    Str(Vec<u8>),
    Array(Vec<PdfObject>),
    Dict(IndexMap<Vec<u8>, PdfObject>),
    Reference(ObjectId),
    Stream(PdfStream),
}
Expand description

A PDF object.

This enum represents all 8 PDF object types plus an indirect reference. Stream objects are represented separately as they contain both a dictionary and binary data.

Variants§

§

Null

The null object.

§

Bool(bool)

A boolean value.

§

Integer(i64)

An integer value (PDF integers are at least 32-bit).

§

Real(f64)

A real (floating-point) value.

§

Name(Vec<u8>)

A name object (e.g., /Type, /Page). Stored without the leading ‘/’.

§

Str(Vec<u8>)

A string object (literal or hex string).

§

Array(Vec<PdfObject>)

An array of objects.

§

Dict(IndexMap<Vec<u8>, PdfObject>)

A dictionary mapping name keys to object values.

§

Reference(ObjectId)

A reference to an indirect object.

§

Stream(PdfStream)

A stream object (dictionary + binary data). The data is stored in decoded (uncompressed) form when possible.

Implementations§

Source§

impl PdfObject

Source

pub fn is_null(&self) -> bool

Source

pub fn is_bool(&self) -> bool

Source

pub fn is_integer(&self) -> bool

Source

pub fn is_number(&self) -> bool

Source

pub fn is_name(&self) -> bool

Source

pub fn is_string(&self) -> bool

Source

pub fn is_array(&self) -> bool

Source

pub fn is_dict(&self) -> bool

Source

pub fn is_stream(&self) -> bool

Source

pub fn is_reference(&self) -> bool

Source

pub fn as_bool(&self) -> Option<bool>

Source

pub fn as_i64(&self) -> Option<i64>

Source

pub fn as_f64(&self) -> Option<f64>

Source

pub fn as_name(&self) -> Option<&[u8]>

Source

pub fn as_name_str(&self) -> Option<String>

Get name as a UTF-8 string (lossy).

Source

pub fn as_str(&self) -> Option<&[u8]>

Source

pub fn as_array(&self) -> Option<&[PdfObject]>

Source

pub fn as_array_mut(&mut self) -> Option<&mut Vec<PdfObject>>

Source

pub fn as_dict(&self) -> Option<&IndexMap<Vec<u8>, PdfObject>>

Source

pub fn as_dict_mut(&mut self) -> Option<&mut IndexMap<Vec<u8>, PdfObject>>

Source

pub fn as_reference(&self) -> Option<ObjectId>

Source

pub fn as_stream(&self) -> Option<&PdfStream>

Source

pub fn dict_get(&self, key: &[u8]) -> Option<&PdfObject>

Look up a key in a dictionary (or stream dictionary).

Source

pub fn dict_get_i64(&self, key: &[u8]) -> Option<i64>

Look up a key and get it as an integer.

Source

pub fn dict_get_f64(&self, key: &[u8]) -> Option<f64>

Look up a key and get it as a float.

Source

pub fn dict_get_name(&self, key: &[u8]) -> Option<&[u8]>

Look up a key and get it as a name.

Source

pub fn dict_get_name_str(&self, key: &[u8]) -> Option<String>

Look up a key and get it as a name string.

Source

pub fn dict_get_bool(&self, key: &[u8]) -> Option<bool>

Look up a key and get it as a boolean.

Trait Implementations§

Source§

impl Clone for PdfObject

Source§

fn clone(&self) -> PdfObject

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PdfObject

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PdfObject

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for PdfObject

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for PdfObject

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.