Struct lopdf::Document
[−]
[src]
pub struct Document { pub version: String, pub trailer: Dictionary, pub reference_table: Xref, pub objects: BTreeMap<ObjectId, Object>, pub max_id: u32, }
PDF document.
Fields
version: String
The version of the PDF specification to which the file conforms.
trailer: Dictionary
The trailer gives the location of the cross-reference table and of certain special objects.
reference_table: Xref
The cross-reference table contains locations of the indirect objects.
objects: BTreeMap<ObjectId, Object>
The objects that make up the document contained in the file.
max_id: u32
Current maximum object id within the document.
Methods
impl Document
[src]
fn new() -> Document
[src]
Create new PDF document.
fn get_object(&self, id: ObjectId) -> Option<&Object>
[src]
Get object by object id, will recursively dereference a referenced object.
fn get_object_mut(&mut self, id: ObjectId) -> Option<&mut Object>
[src]
Get mutable reference to object by object id, will recursively dereference a referenced object.
fn get_dictionary(&self, id: ObjectId) -> Option<&Dictionary>
[src]
Get dictionary object by id.
fn traverse_objects<A: Fn(&mut Object)>(&mut self, action: A) -> Vec<ObjectId>
[src]
Traverse objects from trailer recursively, return all referenced object IDs.
fn catalog(&self) -> Option<&Dictionary>
[src]
Get catalog dictionary.
fn get_pages(&self) -> BTreeMap<u32, ObjectId>
[src]
Get page numbers and corresponding object ids.
fn get_page_contents(&self, page_id: ObjectId) -> Vec<ObjectId>
[src]
Get content stream object ids of a page.
fn get_page_content(&self, page_id: ObjectId) -> Result<Vec<u8>>
[src]
Get content of a page.
fn get_page_fonts(&self, page_id: ObjectId) -> BTreeMap<String, &Dictionary>
[src]
Get fonts used by a page.
fn get_font_encoding<'a>(&'a self, font: &'a Dictionary) -> &str
[src]
fn decode_text<'a>(encoding: Option<&'a str>, bytes: &'a [u8]) -> String
[src]
fn encode_text<'a>(encoding: Option<&'a str>, text: &'a str) -> Vec<u8>
[src]
impl Document
[src]
fn load<P: AsRef<Path>>(path: P) -> Result<Document>
[src]
Load PDF document from specified file path.
fn load_from<R: Read>(source: R) -> Result<Document>
[src]
Load PDF document from arbitrary source
impl Document
[src]
fn save<P: AsRef<Path>>(&mut self, path: P) -> Result<File>
[src]
Save PDF document to specified file path.
fn save_to<W: Write>(&mut self, target: &mut W) -> Result<()>
[src]
Save PDF to arbitrary target
impl Document
[src]
fn with_version<S: Into<String>>(version: S) -> Document
[src]
Create new PDF document with version.
fn new_object_id(&mut self) -> ObjectId
[src]
Create an object ID.
fn add_object<T: Into<Object>>(&mut self, object: T) -> ObjectId
[src]
Add PDF object into document's object list.
impl Document
[src]
fn change_producer(&mut self, producer: &str)
[src]
Change producer of document information dictionary.
fn compress(&mut self)
[src]
Compress PDF stream objects.
fn decompress(&mut self)
[src]
Decompress PDF stream objects.
fn delete_pages(&mut self, page_numbers: &[u32])
[src]
Delete pages.
fn prune_objects(&mut self) -> Vec<ObjectId>
[src]
Prune all unused objects.
fn delete_object(&mut self, id: &ObjectId) -> Option<Object>
[src]
Delete object by object ID.
fn delete_zero_length_streams(&mut self) -> Vec<ObjectId>
[src]
Delete zero length stream objects.
fn renumber_objects(&mut self)
[src]
Renumber objects, normally called after delete_unused_objects.