Convert PDF pages to PNG, JPEG, or WebP with sub-pixel accuracy. Runs server-side, in Lambda, or via WASM.
use pdfluent::{Sdk, RenderOptions, ImageFormat};
fn main() -> pdfluent::Result<()> {
let sdk = Sdk::new()?;
let doc = sdk.open("input.pdf")?;
let opts = RenderOptions::builder()
.dpi(150)
.format(ImageFormat::Png)
.build();
let image = doc.render_page(0, opts)?;
image.save("page-0.png")?;
println!("Rendered {} bytes", image.len());
Ok(())
}Run cargo add pdfluent to get started.
Render at any DPI from 72 to 600. Set DPI per-page or globally. Output pixel dimensions scale exactly with the DPI value you specify.
Outputs sRGB by default. Supports CMYK-to-RGB conversion and grayscale rendering. Color profiles embedded in the PDF are honored during conversion.
Render a specific crop box region instead of the full page. Pass a rectangle in PDF user space coordinates. Useful for extracting figures or thumbnails from a section of a page.
The same render API compiles to WebAssembly. Run PDF-to-image conversion in the browser or in Cloudflare Workers without any server round-trip.
Render all pages in a loop or in parallel using Rayon. Each call to render_page is stateless and thread-safe. Typical throughput is 80-120 pages per second at 96 DPI on a 4-core machine.
PDFluent does not call X11, Wayland, CoreGraphics, or any OS display API. It works on headless Linux servers, in containers, and in Lambda without extra configuration.