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>
impl<S: PdfSource> ObjectStore<S>
Sourcepub fn open(source: S, mode: ParsingMode) -> Result<Self, PdfError>
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.
Sourcepub fn open_with_password(
source: S,
mode: ParsingMode,
password: Option<&str>,
) -> Result<Self, PdfError>
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.
Sourcepub fn resolve(&self, id: ObjectId) -> Result<&Object, PdfError>
pub fn resolve(&self, id: ObjectId) -> Result<&Object, PdfError>
Resolve an indirect object by its ID. Returns a reference to the lazily-parsed object.
Sourcepub fn deep_resolve<'a>(
&'a self,
obj: &'a Object,
) -> Result<&'a Object, PdfError>
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.
Sourcepub fn dict_resolve<'a>(
&'a self,
dict: &'a HashMap<Name, Object>,
key: &Name,
) -> Result<Option<&'a Object>, PdfError>
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.
Sourcepub fn decode_stream(&self, stream: &Object) -> Result<Vec<u8>, PdfError>
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.
Sourcepub fn parsing_mode(&self) -> ParsingMode
pub fn parsing_mode(&self) -> ParsingMode
Get the parsing mode.
Sourcepub fn trailer(&self) -> &TrailerInfo
pub fn trailer(&self) -> &TrailerInfo
Get the trailer info.
Sourcepub fn version(&self) -> PdfVersion
pub fn version(&self) -> PdfVersion
Get the PDF version from the header.
Sourcepub fn object_count(&self) -> usize
pub fn object_count(&self) -> usize
Get the number of object slots.
Sourcepub fn object_ids(&self) -> impl Iterator<Item = &ObjectId>
pub fn object_ids(&self) -> impl Iterator<Item = &ObjectId>
Get all known object IDs.
Sourcepub fn security_handler(&self) -> Option<&SecurityHandler>
pub fn security_handler(&self) -> Option<&SecurityHandler>
Returns a reference to the security handler, if the document is encrypted.
Sourcepub fn source_data(&self) -> &S
pub fn source_data(&self) -> &S
Returns a reference to the raw source data.
Sourcepub fn xref_start_offset(&self) -> u64
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.
Sourcepub fn max_object_number(&self) -> u32
pub fn max_object_number(&self) -> u32
Returns the maximum object number in the store.
Sourcepub fn decode_stream_for_object(
&self,
stream: &Object,
obj_id: ObjectId,
) -> Result<Vec<u8>, PdfError>
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.
Sourcepub fn raw_stream_bytes_for_object(
&self,
stream: &Object,
obj_id: ObjectId,
) -> Result<Vec<u8>, PdfError>
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.