pub struct Metadata { /* private fields */ }Expand description
PDF document metadata.
Contains standard PDF metadata fields. All fields are optional since PDFs may have incomplete or missing metadata.
§Example
use pdfvec::{Extractor, Result};
fn main() -> Result<()> {
let data = std::fs::read("document.pdf")?;
let meta = Extractor::new().extract_metadata(&data)?;
println!("Title: {:?}", meta.title());
println!("Author: {:?}", meta.author());
println!("Pages: {}", meta.page_count());
Ok(())
}Implementations§
Source§impl Metadata
impl Metadata
Sourcepub fn title(&self) -> Option<&str>
pub fn title(&self) -> Option<&str>
Returns the document title, if present.
§Example
let meta = Extractor::new().extract_metadata(&data)?;
if let Some(title) = meta.title() {
println!("Document: {title}");
}Returns the document author, if present.
Sourcepub fn keywords(&self) -> Option<&str>
pub fn keywords(&self) -> Option<&str>
Returns the document keywords, if present.
Keywords are typically comma or space separated.
Sourcepub fn creator(&self) -> Option<&str>
pub fn creator(&self) -> Option<&str>
Returns the application that created the original document.
Sourcepub fn creation_date(&self) -> Option<DateTime<Utc>>
pub fn creation_date(&self) -> Option<DateTime<Utc>>
Returns the document creation date, if present and valid.
§Example
let meta = Extractor::new().extract_metadata(&data)?;
if let Some(date) = meta.creation_date() {
println!("Created: {}", date.format("%Y-%m-%d"));
}Sourcepub fn modification_date(&self) -> Option<DateTime<Utc>>
pub fn modification_date(&self) -> Option<DateTime<Utc>>
Returns the document modification date, if present and valid.
Sourcepub fn page_count(&self) -> u32
pub fn page_count(&self) -> u32
Returns the number of pages in the document.
Returns true if the document has an author.
Trait Implementations§
impl Eq for Metadata
impl StructuralPartialEq for Metadata
Auto Trait Implementations§
impl Freeze for Metadata
impl RefUnwindSafe for Metadata
impl Send for Metadata
impl Sync for Metadata
impl Unpin for Metadata
impl UnwindSafe for Metadata
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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