| Crates.io | pdf-thumb |
| lib.rs | pdf-thumb |
| version | 0.3.0 |
| created_at | 2025-02-06 04:47:33.921683+00 |
| updated_at | 2025-02-07 00:43:54.010031+00 |
| description | PDF thumbnail image generator for Windows |
| homepage | |
| repository | https://github.com/zxrs/pdf-thumb |
| max_upload_size | |
| id | 1545064 |
| size | 18,620 |
This library is a thin wrapper of WinRT PdfDocument Class to generate a thumbnail image for PDF.
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(())
}