use pdfluent::{ImageFormat, PdfDocument, ToImagesOptions};
let doc = PdfDocument::open("document.pdf")?;
// The page number goes in as `{page}`. Without that marker `to_images`
// appends `_N` before the extension instead, so a pattern is never wrong
// in a way the compiler can see.
//
// ToImagesOptions is #[non_exhaustive]: it takes the builder, not a struct
// literal, so that a new option is not a breaking change.
let report = doc.to_images(
"page_{page}.png",
ToImagesOptions::new()
.with_dpi(150)
.with_format(ImageFormat::Png),
)?;
println!("{} pages rendered", report.paths.len());Note: The page compared rendering speed and SSIM quality with MuPDF and Poppler. Its figures were pre-release estimates on a test rig that cannot be traced to any recorded run, so it was withdrawn on 2026-10-15. Measured, dated results are on /benchmarks/text-extraction-vs-docling/ and in the 1.1.0 release notes.