pub struct Document { /* private fields */ }Expand description
A fully extracted PDF document.
Contains all pages and provides convenient access patterns.
§Example
use pdfvec::{Extractor, Result};
fn main() -> Result<()> {
let data = std::fs::read("document.pdf")?;
let doc = Extractor::new().extract_document(&data)?;
println!("Extracted {} pages", doc.page_count());
for page in doc.pages() {
println!("Page {}: {} chars", page.number(), page.char_count());
}
Ok(())
}Implementations§
Source§impl Document
impl Document
Sourcepub fn page_count(&self) -> usize
pub fn page_count(&self) -> usize
Returns the number of pages in the document.
Sourcepub fn page(&self, number: u32) -> Option<&Page>
pub fn page(&self, number: u32) -> Option<&Page>
Returns a specific page by 1-indexed number.
Returns None if the page number is out of range.
Sourcepub fn into_pages(self) -> Vec<Page>
pub fn into_pages(self) -> Vec<Page>
Consumes the document and returns all pages.
Sourcepub fn text(&self, separator: &str) -> String
pub fn text(&self, separator: &str) -> String
Returns all text concatenated with the given separator.
Sourcepub fn full_text(&self) -> String
pub fn full_text(&self) -> String
Returns all text concatenated with default separator (double newline).
Sourcepub fn total_chars(&self) -> usize
pub fn total_chars(&self) -> usize
Returns total character count across all pages.
Trait Implementations§
Source§impl<'a> IntoIterator for &'a Document
impl<'a> IntoIterator for &'a Document
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnwindSafe for Document
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more