Rasterize individual pages or an entire PDF document to JPEG files at a configurable DPI and quality level.
use pdfluent::prelude::*;
fn main() -> Result<()> {
let doc = PdfDocument::open("document.pdf")?;
let report = doc.to_images(
"page_{page}.jpg",
ToImagesOptions::new()
.with_dpi(150)
.with_format(ImageFormat::Jpeg),
)?;
println!("rendered {} pages", report.paths.len());
Ok(())
}Load the document.
use pdfluent::prelude::*;
let doc = PdfDocument::open("document.pdf")?;ToImagesOptions defaults to PNG; switch to Jpeg with with_format. JPEG quality is fixed at 90 in 1.0; user-configurable quality is tracked for a later release.
let opts = ToImagesOptions::new()
.with_dpi(150)
.with_format(ImageFormat::Jpeg);The {page} placeholder in the pattern is substituted with the 1-based page number.
let report = doc.to_images("page_{page}.jpg", opts)?;No JVM, no runtime, no DLL dependencies. Ships as a single native binary or WASM module.
Rust's ownership model prevents buffer overflows and use-after-free. No segfaults in PDF parsing.
Same code runs server-side, in Docker, on AWS Lambda, on Cloudflare Workers, or in the browser via WASM.