Crate pdf2image

Source
Expand description

§Overview

This crate is a simplified port of Python’s pdf2image that wraps pdftoppm and pdftocairo (part of poppler) to convert PDFs to image::DynamicImages.

It requires poppler to be installed on your system. You can follow the instructions found in the README.md file which is most easily viewed on github.

§Quick Start

use pdf2image::{PDF2ImageError, RenderOptionsBuilder, PDF};
 
fn main() -> Result<(), PDF2ImageError> {
    let pdf = PDF::from_file("examples/pdfs/ropes.pdf").unwrap();
    let pages = pdf.render(
        pdf2image::Pages::Range(1..=8),
        RenderOptionsBuilder::default().build()?,
    );
    println!("{:?}", pages.unwrap().len());
 
    Ok(())
}

Re-exports§

pub use image;

Structs§

Crop
Crop a specific section of the page
PDF
A PDF file
RenderOptions
Options for rendering PDFs
RenderOptionsBuilder
Builder for RenderOptions.

Enums§

DPI
Specifies resolution in terms of dots per inch
PDF2ImageError
pdf2img error variants
Pages
Specifies which pages to render
Password
Password to unlock encrypted PDFs
Scale
Scales pages to a certain number of pixels

Type Aliases§

Result
A Result type alias using PDF2ImgError instances as the error variant.