Skip to main content

File

Struct File 

Source
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

Source

pub fn open( source: Arc<dyn Source + Sync + Send>, options: OpenOptions, ) -> Result<File, Error>

Opens source.

Source

pub fn header(&self) -> Option<Header>

The header, if one was found.

Source

pub fn trailer(&self) -> &Dict

The (merged) trailer dictionary.

Source

pub fn entries(&self) -> &BTreeMap<u32, XrefEntry>

The xref entries, by object number.

Source

pub fn sections(&self) -> &[u64]

Offsets of the xref sections read, newest first. One per revision for an incrementally updated file.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn read_all(&self) -> Result<Vec<u8>, Error>

The whole source, as an incremental save copies it.

Source

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

The security handler, if the file is encrypted.

Source

pub fn diagnostics(&self) -> Vec<Diagnostic>

Repairs made so far.

Source

pub fn diagnostics_sink(&self) -> &Diagnostics

The diagnostics sink, for higher layers to add to.

Source

pub fn limits(&self) -> &Limits

The limits in force.

Source

pub fn strictness(&self) -> Strictness

Whether repairs are allowed.

Source

pub fn len(&self) -> u64

File length in bytes.

Source

pub fn is_empty(&self) -> bool

Whether the file is empty.

Source

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”.

Source

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.

Source

pub fn resolve_dict(&self, object: &Object) -> Option<Dict>

Resolves object as a dictionary (or a stream’s dictionary).

Source

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.

Trait Implementations§

Source§

impl Debug for File

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for File

§

impl !RefUnwindSafe for File

§

impl !UnwindSafe for File

§

impl Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl UnsafeUnpin for File

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> ErasedDestructor for T
where T: 'static,

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.