Rasterize individual pages or an entire PDF document to JPEG files at a configurable DPI and quality level.
use pdfluent::{PdfDocument, ImageFormat};
fn main() -> pdfluent::Result<()> {
let doc = PdfDocument::open("file.pdf")?;
let jpg = doc.render_page(0, 150, ImageFormat::Jpeg)?;
std::fs::write("page-1.jpg", jpg)?;
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.