Repository navigation
Home
Pure Rust PDF → 8-bit greyscale pixel pipeline, built for OCR.
pdf-raster converts PDF pages into raw 8-bit greyscale pixel buffers with no Poppler,
no subprocesses, and no Leptonica in the render path. Each page comes back as a
RenderedPage containing a flat Vec<u8> of pixels, ready to hand directly to
Tesseract, ocrs, Google Cloud Vision, GPT-5, Mistral, or any other OCR/vision engine.
GPU acceleration is available via CUDA (nvJPEG, AA fill, ICC CLUT) and Vulkan
(cross-vendor, AMD/Intel/Apple).
[dependencies]
pdf_raster = { git = "https://github.com/pthomasfournet/pdf-raster", tag = "v0.8.0" }use pdf_raster::{raster_pdf, RasterOptions};
let opts = RasterOptions {
dpi: 300.0,
first_page: 1,
last_page: u32::MAX,
deskew: false,
pages: None,
};
for (page_num, result) in raster_pdf("document.pdf", opts) {
let page = result?;
println!(
"page {}: {}x{} @ {:.0} dpi, {} bytes",
page_num,
page.width,
page.height,
page.effective_dpi,
page.pixels.len()
);
// page.pixels is a flat Vec<u8> of 8-bit greyscale samples,
// row-major, width x height bytes total.
}Always use
page.effective_dpi, not thedpiyou passed in — it accounts for PDFUserUnitscaling, which can silently change the true resolution.
| Guide | Engines |
|---|---|
| OCR Integration | Tesseract (leptess), ocrs |
| LLM Vision OCR Integration | Google Cloud Vision, GPT-5, Mistral |
| Symbol | Description |
|---|---|
raster_pdf(path, opts) |
Iterator yielding (page_num, Result<RenderedPage>)
|
render_channel(path, opts, capacity) |
Channel-based pipeline for concurrent OCR workers |
RasterOptions |
dpi, first_page, last_page, deskew, pages
|
RenderedPage |
pixels, width, height, dpi, effective_dpi
|
render_channel is the better choice when you have a pool of OCR workers — it keeps
the rasterizer and workers running concurrently rather than serialising them.
[dependencies]
pdf_raster = { git = "https://github.com/pthomasfournet/pdf-raster", tag = "v0.8.0" }The crate is GitHub-distributed only (not published to crates.io).
- Main repository README — build instructions, GPU feature flags, benchmark results, and the full crate map.
Pure Rust PDF → pixels pipeline. No Poppler. No subprocesses.
- OCR Integration Tesseract · ocrs
- LLM Vision OCR Cloud Vision · GPT-5 · Mistral
- Benchmarks CPU · GPU · version history