Skip to main content

Document

Struct Document 

Source
pub struct Document { /* private fields */ }
Expand description

a PDF document opened for reading

Implementations§

Source§

impl Document

Source

pub fn named_dest(&self, name: &str) -> Option<Dest>

a named destination (“chapter1”)

Source

pub fn outlines(&self) -> Vec<Outline>

the outline (bookmarks)

Source

pub fn annotations(&self, page: usize) -> Result<Vec<Annotation>, Error>

the annotations of a page

the links of a page: (rectangle, action)

Source

pub fn fields(&self) -> Vec<Field>

the fields of the interactive form (the AcroForm), terminal fields only

Source

pub fn attachments(&self) -> Vec<Attachment>

the embedded files: the /EmbeddedFiles name tree, then file attachment annotations

Source

pub fn page_label(&self, page: usize) -> Option<String>

a page’s label (12.4.2: “iv”, “A-3”); None when the document sets no labels

Source§

impl Document

Source

pub fn page_pixels(&self, page: usize, dpi: f64) -> Result<(u32, u32), Error>

the size of a page drawn at dpi: width and height in pixels (the crop box after /Rotate)

Source

pub fn render(&self, page: usize, opt: &RenderOptions) -> Result<Surface, Error>

draw a page into a new surface (premultiplied ARGB, gfx::FMT_PARGB)

Source§

impl Document

Source

pub fn page_text(&self, page: usize) -> Result<PageText, Error>

the glyphs of a page, in the order the page draws them

Source

pub fn text(&self, page: usize) -> Result<String, Error>

the text of a page in reading order (PageText::text)

Source§

impl Document

Source

pub fn open(data: Vec<u8>) -> Result<Document, Error>

open a document without a password

Source

pub fn open_with(data: Vec<u8>, opt: &Options) -> Result<Document, Error>

Source

pub fn version(&self) -> (u8, u8)

the version of the header, or of the catalog’s /Version when that is newer

Source

pub fn is_encrypted(&self) -> bool

Source

pub fn permissions(&self) -> Option<u32>

the permission bits /P of an encrypted file (ISO 32000-1, Table 22: bit 3 print, 4 modify, 5 copy text and graphics, 6 annotate, 9 fill in forms, 10 extract for accessibility, 11 assemble, 12 print in high quality; counted from 1)

Source

pub fn encryption_revision(&self) -> Option<u8>

the revision of the standard security handler (2 to 6) of an encrypted file

Source

pub fn opened_as_owner(&self) -> bool

the password given was the owner password

Source

pub fn was_repaired(&self) -> bool

the cross-reference was rebuilt from the objects of the file

Source

pub fn trailer(&self) -> &Dict

Source

pub fn catalog(&self) -> Dict

the document catalog (empty when there is none)

Source

pub fn data(&self) -> &[u8] ⓘ

the raw bytes of the file

Source

pub fn get(&self, r: Ref) -> Object

an indirect object (Null when it is missing, as ISO 32000 has it)

Source

pub fn resolve(&self, o: &Object) -> Object

follow references until an object that is none (Null after too many)

Source

pub fn decode(&self, s: &Stream) -> Result<Vec<u8>, Error>

Source

pub fn decode_until_image( &self, s: &Stream, ) -> Result<(Vec<u8>, Option<(Name, Dict)>), Error>

a stream’s data with its filters applied up to an image filter: the data, and the image filter with its parameters (DCTDecode is a JPEG file then, JPXDecode a JPEG 2000 one)

Source

pub fn page_count(&self) -> usize

Source

pub fn pages(&self) -> &[Page]

Source

pub fn page(&self, i: usize) -> Result<&Page, Error>

Source

pub fn page_of(&self, r: Ref) -> Option<usize>

the page a page object is (for destinations)

Source

pub fn contents(&self, i: usize) -> Result<Vec<u8>, Error>

the content of a page: its content streams decoded and joined (a stream that cannot be decoded adds nothing)

Source

pub fn info(&self) -> Info

the document information (the Info dictionary; dates as the file writes them)

Source

pub fn metadata(&self) -> Option<Vec<u8>>

the XMP metadata of the document (the catalog’s /Metadata stream)

Source

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

the natural language of the document (/Lang: “de-DE”)

Auto Trait Implementations§

§

impl !Freeze for Document

§

impl !RefUnwindSafe for Document

§

impl !Send for Document

§

impl !Sync for Document

§

impl !UnwindSafe for Document

§

impl Forget for Document

§

impl Move for Document

§

impl Unpin for Document
where *const u8 is !null: Unpin, *const LeafNode<u32, (Entry, u16)> is !null: Unpin, Box<(u32, (Entry, u16))>: Unpin, Arc<BTreeMap<Name, Object>>: Unpin, *const LeafNode<u32, usize> is !null: Unpin, Box<(u32, usize)>: Unpin, *const LeafNode<u32, (usize, u16)> is !null: Unpin, Box<(u32, (usize, u16))>: Unpin, *const LeafNode<u32, Option<Rc<ObjStm>>> is !null: Unpin, Box<(u32, Option<Rc<ObjStm>>)>: Unpin, *const LeafNode<Name, Method> is !null: Unpin, Box<(Name, Method)>: Unpin, *const LeafNode<Ref, usize> is !null: Unpin, Box<(Ref, usize)>: Unpin, *const LeafNode<Ref, Rc<GFont>> is !null: Unpin, Box<(Ref, Rc<GFont>)>: Unpin, *const LeafNode<(usize, u32, [u64; 4], u8), (Rc<GFont>, Option<Rc<Cover>>)> is !null: Unpin, Box<((usize, u32, [u64; 4], u8), (Rc<GFont>, Option<Rc<Cover>>))>: Unpin, *const LeafNode<(String, bool, bool, bool, Option<String>), Option<Rc<Prog>>> is !null: Unpin, Box<((String, bool, bool, bool, Option<String>), Option<Rc<Prog>>)>: Unpin, *const LeafNode<(usize, usize, u64), Option<Rc<Prog>>> is !null: Unpin, Box<((usize, usize, u64), Option<Rc<Prog>>)>: Unpin, Rc<dyn FontSource>: Unpin, *const LeafNode<Ref, Option<Rc<Icc>>> is !null: Unpin, Box<(Ref, Option<Rc<Icc>>)>: Unpin, Rc<Cell<usize>>: Unpin, *const LeafNode<Ref, Rc<BTreeMap<char, (u32, u8, f64)>>> is !null: Unpin, Box<(Ref, Rc<BTreeMap<char, (u32, u8, f64)>>)>: Unpin, *const LeafNode<Vec<u8>, Option<Rc<CMap>>> is !null: Unpin, Box<(Vec<u8>, Option<Rc<CMap>>)>: Unpin, *const LeafNode<Collection, Rc<ToUnicode>> is !null: Unpin, Box<(Collection, Rc<ToUnicode>)>: Unpin,

§

impl UnsafeUnpin for Document
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const LeafNode<u32, (Entry, u16)> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(u32, (Entry, u16))>>: UnsafeUnpin, *const ArcInner<BTreeMap<Name, Object>> is !null: UnsafeUnpin, PhantomData<ArcInner<BTreeMap<Name, Object>>>: UnsafeUnpin, PhantomData<u32>: UnsafeUnpin, *const LeafNode<u32, usize> is !null: UnsafeUnpin, PhantomData<Box<(u32, usize)>>: UnsafeUnpin, *const LeafNode<u32, (usize, u16)> is !null: UnsafeUnpin, PhantomData<Box<(u32, (usize, u16))>>: UnsafeUnpin, PhantomData<usize>: UnsafeUnpin, *const LeafNode<u32, Option<Rc<ObjStm>>> is !null: UnsafeUnpin, PhantomData<Box<(u32, Option<Rc<ObjStm>>)>>: UnsafeUnpin, *const LeafNode<Name, Method> is !null: UnsafeUnpin, PhantomData<Box<(Name, Method)>>: UnsafeUnpin, PhantomData<Page>: UnsafeUnpin, *const LeafNode<Ref, usize> is !null: UnsafeUnpin, PhantomData<Box<(Ref, usize)>>: UnsafeUnpin, *const LeafNode<Ref, Rc<GFont>> is !null: UnsafeUnpin, PhantomData<Box<(Ref, Rc<GFont>)>>: UnsafeUnpin, *const LeafNode<(usize, u32, [u64; 4], u8), (Rc<GFont>, Option<Rc<Cover>>)> is !null: UnsafeUnpin, PhantomData<Box<((usize, u32, [u64; 4], u8), (Rc<GFont>, Option<Rc<Cover>>))>>: UnsafeUnpin, *const LeafNode<(String, bool, bool, bool, Option<String>), Option<Rc<Prog>>> is !null: UnsafeUnpin, PhantomData<Box<((String, bool, bool, bool, Option<String>), Option<Rc<Prog>>)>>: UnsafeUnpin, *const LeafNode<(usize, usize, u64), Option<Rc<Prog>>> is !null: UnsafeUnpin, PhantomData<Box<((usize, usize, u64), Option<Rc<Prog>>)>>: UnsafeUnpin, *const RcInner<dyn FontSource> is !null: UnsafeUnpin, PhantomData<RcInner<dyn FontSource>>: UnsafeUnpin, *const LeafNode<Ref, Option<Rc<Icc>>> is !null: UnsafeUnpin, PhantomData<Box<(Ref, Option<Rc<Icc>>)>>: UnsafeUnpin, *const RcInner<Cell<usize>> is !null: UnsafeUnpin, PhantomData<RcInner<Cell<usize>>>: UnsafeUnpin, *const LeafNode<Ref, Rc<BTreeMap<char, (u32, u8, f64)>>> is !null: UnsafeUnpin, PhantomData<Box<(Ref, Rc<BTreeMap<char, (u32, u8, f64)>>)>>: UnsafeUnpin, *const LeafNode<Vec<u8>, Option<Rc<CMap>>> is !null: UnsafeUnpin, PhantomData<Box<(Vec<u8>, Option<Rc<CMap>>)>>: UnsafeUnpin, *const LeafNode<Collection, Rc<ToUnicode>> is !null: UnsafeUnpin, PhantomData<Box<(Collection, Rc<ToUnicode>)>>: UnsafeUnpin,

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