@omsimos/pdf-raster
v0.1.1
Published
High-performance PDF to image conversion for Node.js and Bun.
Maintainers
Readme
@omsimos/pdf-raster
Blazing fast, native PDF-to-image conversion for Node.js and Bun.
@omsimos/pdf-raster renders PDF pages into high-quality image buffers through
a small, high-performance server-side API. Built with Rust and PDFium, it is
roughly 4x–8x faster than the included pdfjs-dist canvas backends in the
current local benchmark sample.
📦 Install
# Bun
bun add @omsimos/pdf-raster
# PNPM
pnpm add @omsimos/pdf-raster
# NPM
npm install @omsimos/pdf-raster🚀 Quick Usage
import { convert } from "@omsimos/pdf-raster";
const [page] = await convert("./report.pdf", {
pages: [0], // 0-indexed page numbers
dpi: 300, // High resolution for OCR and VLM inputs
});
// page.data is the encoded image buffer (default: png)
console.log({
pageIndex: page.pageIndex,
mimeType: page.mimeType,
width: page.width,
height: page.height,
});Output Types
type ConvertedPage = {
pageIndex: number;
data: Buffer;
mimeType: "image/png" | "image/jpeg" | "image/webp";
width: number;
height: number;
dpi: number;
};⚡ Performance
Tested on Apple Silicon (M4) against the included fixture PDFs at 300 DPI.
- @omsimos/pdf-raster: ~0.86 ms/page
pdfjs-dist + @napi-rs/canvas: ~5.98 ms/page (~6.9xslower)pdfjs-dist + node-canvas: ~7.19 ms/page (~8.4xslower)
[!NOTE] These are sample local benchmark results, not universal guarantees. Run
bun run benchmarkin the repository if you want to compare on your own machine.
🌍 Runtime Support
- Server-side only: Node.js and Bun.
- Targets: macOS (x64/arm64), Linux (x64/arm64), Windows (x64/arm64).
- Format Support:
png(default),jpeg,webp.
[!CAUTION] This package contains native bindings. It will not work in Browser bundles, React Client Components, or Edge runtimes.
