[−][src]Struct lopdf::Document
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]
pub fn new() -> Document
[src]
Create new PDF document.
pub fn dereference<'a>(
&'a self,
object: &'a Object
) -> Result<(Option<ObjectId>, &'a Object)>
[src]
&'a self,
object: &'a Object
) -> Result<(Option<ObjectId>, &'a Object)>
Follow references if the supplied object is a reference.
Returns a tuple of an optional object id and final object. The object id will be None if the object was not a reference. Otherwise, it will be the last object id in the reference chain.
pub fn get_object(&self, id: ObjectId) -> Result<&Object>
[src]
Get object by object id, will iteratively dereference a referenced object.
pub fn get_object_mut(&mut self, id: ObjectId) -> Result<&mut Object>
[src]
Get mutable reference to object by object id, will iteratively dereference a referenced object.
pub fn get_dictionary(&self, id: ObjectId) -> Result<&Dictionary>
[src]
Get dictionary object by id.
pub fn traverse_objects<A: Fn(&mut Object)>(
&mut self,
action: A
) -> Vec<ObjectId>
[src]
&mut self,
action: A
) -> Vec<ObjectId>
Traverse objects from trailer recursively, return all referenced object IDs.
pub fn catalog(&self) -> Result<&Dictionary>
[src]
Get catalog dictionary.
pub fn get_pages(&self) -> BTreeMap<u32, ObjectId>
[src]
Get page numbers and corresponding object ids.
pub fn page_iter(&self) -> impl Iterator<Item = ObjectId> + '_
[src]
pub fn get_page_contents(&self, page_id: ObjectId) -> Vec<ObjectId>
[src]
Get content stream object ids of a page.
pub fn get_page_content(&self, page_id: ObjectId) -> Result<Vec<u8>>
[src]
Get content of a page.
pub fn get_and_decode_page_content(&self, page_id: ObjectId) -> Result<Content>
[src]
Get decoded page content;
pub fn get_page_resources(
&self,
page_id: ObjectId
) -> (Option<&Dictionary>, Vec<ObjectId>)
[src]
&self,
page_id: ObjectId
) -> (Option<&Dictionary>, Vec<ObjectId>)
Get resources used by a page.
pub fn get_page_fonts(
&self,
page_id: ObjectId
) -> BTreeMap<Vec<u8>, &Dictionary>
[src]
&self,
page_id: ObjectId
) -> BTreeMap<Vec<u8>, &Dictionary>
Get fonts used by a page.
pub fn decode_text(encoding: Option<&str>, bytes: &[u8]) -> String
[src]
pub fn encode_text(encoding: Option<&str>, text: &str) -> Vec<u8>
[src]
impl Document
[src]
pub fn with_version<S: Into<String>>(version: S) -> Document
[src]
Create new PDF document with version.
pub fn new_object_id(&mut self) -> ObjectId
[src]
Create an object ID.
pub fn add_object<T: Into<Object>>(&mut self, object: T) -> ObjectId
[src]
Add PDF object into document's object list.
pub fn get_or_create_resources(
&mut self,
page_id: ObjectId
) -> Result<&mut Object>
[src]
&mut self,
page_id: ObjectId
) -> Result<&mut Object>
pub fn add_xobject<N: Into<Vec<u8>>>(
&mut self,
page_id: ObjectId,
xobject_name: N,
xobject_id: ObjectId
) -> Result<()>
[src]
&mut self,
page_id: ObjectId,
xobject_name: N,
xobject_id: ObjectId
) -> Result<()>
pub fn add_graphics_state<N: Into<Vec<u8>>>(
&mut self,
page_id: ObjectId,
gs_name: N,
gs_id: ObjectId
) -> Result<()>
[src]
&mut self,
page_id: ObjectId,
gs_name: N,
gs_id: ObjectId
) -> Result<()>
impl Document
[src]
pub fn change_producer(&mut self, producer: &str)
[src]
Change producer of document information dictionary.
pub fn compress(&mut self)
[src]
Compress PDF stream objects.
pub fn decompress(&mut self)
[src]
Decompress PDF stream objects.
pub fn delete_pages(&mut self, page_numbers: &[u32])
[src]
Delete pages.
pub fn prune_objects(&mut self) -> Vec<ObjectId>
[src]
Prune all unused objects.
pub fn delete_object(&mut self, id: ObjectId) -> Option<Object>
[src]
Delete object by object ID.
pub fn delete_zero_length_streams(&mut self) -> Vec<ObjectId>
[src]
Delete zero length stream objects.
pub fn renumber_objects(&mut self)
[src]
Renumber objects, normally called after delete_unused_objects.
pub fn extract_text(&self, page_numbers: &[u32]) -> Result<String>
[src]
pub fn change_content_stream(&mut self, stream_id: ObjectId, content: Vec<u8>)
[src]
pub fn change_page_content(
&mut self,
page_id: ObjectId,
content: Vec<u8>
) -> Result<()>
[src]
&mut self,
page_id: ObjectId,
content: Vec<u8>
) -> Result<()>
pub fn replace_text(
&mut self,
page_number: u32,
text: &str,
other_text: &str
) -> Result<()>
[src]
&mut self,
page_number: u32,
text: &str,
other_text: &str
) -> Result<()>
pub fn extract_stream(
&self,
stream_id: ObjectId,
decompress: bool
) -> Result<()>
[src]
&self,
stream_id: ObjectId,
decompress: bool
) -> Result<()>
impl Document
[src]
pub fn load<P: AsRef<Path>>(path: P) -> Result<Document>
[src]
Load a PDF document from a specified file path.
pub fn load_from<R: Read>(source: R) -> Result<Document>
[src]
Load a PDF document from an arbitrary source.
pub fn load_mem(buffer: &[u8]) -> Result<Document>
[src]
Load a PDF document from a memory slice.
impl Document
[src]
pub fn save<P: AsRef<Path>>(&mut self, path: P) -> Result<File>
[src]
Save PDF document to specified file path.
pub fn save_to<W: Write>(&mut self, target: &mut W) -> Result<()>
[src]
Save PDF to arbitrary target
impl Document
[src]
Trait Implementations
impl Clone for Document
[src]
fn clone(&self) -> Document
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for Document
[src]
impl Debug for Document
[src]
impl<'_> TryInto<Document> for &'_ [u8]
[src]
Auto Trait Implementations
impl Unpin for Document
impl Sync for Document
impl Send for Document
impl RefUnwindSafe for Document
impl UnwindSafe for Document
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,