4 releases (2 breaking)
0.3.0 | Feb 7, 2025 |
---|---|
0.2.0 | Feb 6, 2025 |
0.1.2 | Feb 6, 2025 |
0.1.1 |
|
0.1.0 | Feb 6, 2025 |
#336 in Images
485 downloads per month
12KB
196 lines
pdf-thumb
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(())
}
Dependencies
~126MB
~2M SLoC