pub struct PDF { /* private fields */ }Expand description
A PDF file
This struct wraps the bytes of an PDF and additional information about the PDF, such as the number of pages and whether the PDF is encrypted.
§Usage
use pdf2image::{PDF, Pages, RenderOptionsBuilder};
fn main() -> Result<(), pdf2img::Error> {
let pdf = PDF::from_file("examples/pdfs/ropes.pdf")?;
let rendered_pages = pdf.render(Pages::All, RenderOptionsBuilder::default().build()?)?;
}§Rationale
Storing the page count prevents calls to pdfinfo for every call to render().
Implementations§
Source§impl PDF
impl PDF
Sourcepub fn from_bytes(data: Vec<u8>) -> Result<Self>
pub fn from_bytes(data: Vec<u8>) -> Result<Self>
Constructs a PDF from bytes.
Sourcepub fn page_count(&self) -> u32
pub fn page_count(&self) -> u32
Returns the number of pages in the PDF.
Sourcepub fn is_encrypted(&self) -> bool
pub fn is_encrypted(&self) -> bool
Returns whether the PDF is encrypted.
Sourcepub fn render(
&self,
pages: Pages,
options: impl Into<Option<RenderOptions>>,
) -> Result<Vec<DynamicImage>>
pub fn render( &self, pages: Pages, options: impl Into<Option<RenderOptions>>, ) -> Result<Vec<DynamicImage>>
Renders the PDF to images.
Auto Trait Implementations§
impl Freeze for PDF
impl RefUnwindSafe for PDF
impl Send for PDF
impl Sync for PDF
impl Unpin for PDF
impl UnwindSafe for PDF
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> 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