Crate pdf_thumb

Source
Expand description

This library is a thin wrapper of WinRT PdfDocument Class to generate a thumbnail image for PDF.

§Example

use anyhow::Result;
use pdf_thumb::PdfDoc;

fn main() -> Result<()> {
    let pdf = PdfDoc::open("test.pdf")?;
    let thumb = pdf.thumb()?;
    std::fs::write("thumb.png", &thumb)?; // PNG is default.
    Ok(())
}

Some options and async operation are also available.

use anyhow::Result;
use pdf_thumb::{ImageFormat, Options, PdfDoc};

#[tokio::main]
fn main() -> Result<()> {
    let pdf = PdfDoc::open_async("test.pdf").await?;
    let options = Options {
        width: 320,                // Set thumbnail image width.
        format: ImageFormat::Jpeg, // Set thumbnail image format.
        ..Default::default()
    };
    let thumb = pdf.thumb_with_options_async(options).await?;
    tokio::fs::write("thumb.jpg", &thumb).await?;
    Ok(())
}

Structs§

Enums§