pub struct File { /* private fields */ }Expand description
A PDF file opened for reading. Objects are parsed on first access and cached; the file itself is never modified.
Implementations§
Source§impl File
impl File
Sourcepub fn open(
source: Arc<dyn Source + Sync + Send>,
options: OpenOptions,
) -> Result<File, Error>
pub fn open( source: Arc<dyn Source + Sync + Send>, options: OpenOptions, ) -> Result<File, Error>
Opens source.
Sourcepub fn sections(&self) -> &[u64]
pub fn sections(&self) -> &[u64]
Offsets of the xref sections read, newest first. One per revision for an incrementally updated file.
Sourcepub fn startxref(&self) -> Result<Option<u64>, Error>
pub fn startxref(&self) -> Result<Option<u64>, Error>
The value written after the last startxref, as the file states it:
what an incremental update’s /Prev must point to.
Sourcepub fn newest_section_is_stream(&self) -> Result<Option<bool>, Error>
pub fn newest_section_is_stream(&self) -> Result<Option<bool>, Error>
Whether the newest xref section is an xref stream (rather than a
classic table); None when no section was read.
Sourcepub fn offset_shift(&self) -> Result<u64, Error>
pub fn offset_shift(&self) -> Result<u64, Error>
How far offsets written in this file are shifted from absolute byte positions: the header offset when the file has junk before its header and its xref offsets count from the header, else 0. New offsets appended to the file must follow the same convention.
Sourcepub fn was_rebuilt(&self) -> bool
pub fn was_rebuilt(&self) -> bool
Whether the xref had to be rebuilt by scanning. Such a file has no trustworthy revision chain to append to.
Sourcepub fn read_all(&self) -> Result<Vec<u8>, Error>
pub fn read_all(&self) -> Result<Vec<u8>, Error>
The whole source, as an incremental save copies it.
Sourcepub fn security(&self) -> Option<&SecurityHandler>
pub fn security(&self) -> Option<&SecurityHandler>
The security handler, if the file is encrypted.
Sourcepub fn diagnostics(&self) -> Vec<Diagnostic>
pub fn diagnostics(&self) -> Vec<Diagnostic>
Repairs made so far.
Sourcepub fn diagnostics_sink(&self) -> &Diagnostics
pub fn diagnostics_sink(&self) -> &Diagnostics
The diagnostics sink, for higher layers to add to.
Sourcepub fn strictness(&self) -> Strictness
pub fn strictness(&self) -> Strictness
Whether repairs are allowed.
Sourcepub fn get(&self, id: ObjId) -> Result<Arc<Object>, Error>
pub fn get(&self, id: ObjId) -> Result<Arc<Object>, Error>
The object id, decrypted. A missing object is an error here; use
File::resolve for the specification’s “missing is null”.
Sourcepub fn resolve(&self, object: &Object) -> Object
pub fn resolve(&self, object: &Object) -> Object
Follows references until a direct object. Missing objects and
reference chains longer than the depth limit resolve to null.
Sourcepub fn resolve_dict(&self, object: &Object) -> Option<Dict>
pub fn resolve_dict(&self, object: &Object) -> Option<Dict>
Resolves object as a dictionary (or a stream’s dictionary).
Sourcepub fn decode_stream(&self, stream: &Stream) -> Result<Decoded, Error>
pub fn decode_stream(&self, stream: &Stream) -> Result<Decoded, Error>
Decodes a stream’s data through its filters. Image codecs are left
encoded and listed in Decoded::remaining.