Skip to main content

ObjectStore

Struct ObjectStore 

Source
pub struct ObjectStore<S: PdfSource = Arc<[u8]>> { /* private fields */ }
Expand description

The central PDF object store with thread-safe lazy parsing.

Generic over the source data type via PdfSource.

Implementations§

Source§

impl<S: PdfSource> ObjectStore<S>

Source

pub fn open(source: S, mode: ParsingMode) -> Result<Self, PdfError>

Open a PDF source, parsing the header, xref table, and trailer.

This constructs the ObjectStore with all object slots ready for lazy parsing on demand. For encrypted PDFs, use Self::open_with_password.

Source

pub fn open_with_password( source: S, mode: ParsingMode, password: Option<&str>, ) -> Result<Self, PdfError>

Open a PDF source, optionally providing a password for encrypted documents.

After parsing the header, xref, and trailer, if the trailer contains an /Encrypt entry, the encryption dictionary is resolved and a SecurityHandler is created. The password is verified against both user and owner password hashes.

Source

pub fn resolve(&self, id: ObjectId) -> Result<&Object, PdfError>

Resolve an indirect object by its ID. Returns a reference to the lazily-parsed object.

Source

pub fn deep_resolve<'a>( &'a self, obj: &'a Object, ) -> Result<&'a Object, PdfError>

Follow a reference chain to the concrete object.

Uses an iterative loop with circular reference detection via SmallVec. Never recurses on the call stack.

Source

pub fn dict_resolve<'a>( &'a self, dict: &'a HashMap<Name, Object>, key: &Name, ) -> Result<Option<&'a Object>, PdfError>

Resolve a dictionary value by key, following references.

Source

pub fn decode_stream(&self, stream: &Object) -> Result<Vec<u8>, PdfError>

Decode stream data on demand using the filter chain from the stream dictionary.

Resolves /Filter and /DecodeParms from the stream dictionary, then applies the codec pipeline via rpdfium_codec::apply_filter_chain.

Source

pub fn parsing_mode(&self) -> ParsingMode

Get the parsing mode.

Source

pub fn trailer(&self) -> &TrailerInfo

Get the trailer info.

Source

pub fn version(&self) -> PdfVersion

Get the PDF version from the header.

Source

pub fn xref(&self) -> &XrefTable

Get the cross-reference table.

Source

pub fn object_count(&self) -> usize

Get the number of object slots.

Source

pub fn contains(&self, id: ObjectId) -> bool

Check if an object ID exists in the store.

Source

pub fn object_ids(&self) -> impl Iterator<Item = &ObjectId>

Get all known object IDs.

Source

pub fn security_handler(&self) -> Option<&SecurityHandler>

Returns a reference to the security handler, if the document is encrypted.

Source

pub fn source_data(&self) -> &S

Returns a reference to the raw source data.

Source

pub fn xref_start_offset(&self) -> u64

Returns the byte offset of the last startxref value.

This is needed for incremental saves to set the /Prev trailer key.

Source

pub fn max_object_number(&self) -> u32

Returns the maximum object number in the store.

Source

pub fn decode_stream_for_object( &self, stream: &Object, obj_id: ObjectId, ) -> Result<Vec<u8>, PdfError>

Decode stream data for a specific object, applying decryption if needed.

Like Self::decode_stream, but also decrypts the raw stream data before applying the filter chain when the document is encrypted.

Source

pub fn raw_stream_bytes_for_object( &self, stream: &Object, obj_id: ObjectId, ) -> Result<Vec<u8>, PdfError>

Return the raw (optionally decrypted) stream bytes without applying any filter chain. This is useful when the caller needs to handle a specific filter (like JPXDecode) specially to extract metadata.

Source

pub fn decrypt_string(&self, data: &[u8], obj_id: ObjectId) -> Vec<u8>

Decrypt a string value from an encrypted document.

If the document is not encrypted, returns the input bytes unchanged.

Auto Trait Implementations§

§

impl<S> Freeze for ObjectStore<S>
where S: Freeze,

§

impl<S = Arc<[u8]>> !RefUnwindSafe for ObjectStore<S>

§

impl<S> Send for ObjectStore<S>

§

impl<S> Sync for ObjectStore<S>

§

impl<S> Unpin for ObjectStore<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for ObjectStore<S>
where S: UnsafeUnpin,

§

impl<S = Arc<[u8]>> !UnwindSafe for ObjectStore<S>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more