pdf-image-converter
v0.3.0
Published
Convert PDF to images in Node.js (PNG, JPEG, BMP, PPM, ICO, TIFF). Fast, zero-dependency, TypeScript-first with NestJS support.
Downloads
245
Maintainers
Readme
pdf-image-converter
🚀 Convert PDF pages to images in Node.js — fast, lightweight, and zero dependencies.
✨ Why pdf-image-converter?
Stop dealing with heavy tools like ImageMagick or Ghostscript.
pdf-image-converter is a modern, zero-dependency solution built for speed, simplicity, and production use.
✔ No native installs
✔ Works out of the box
✔ Built with TypeScript
✔ Perfect for APIs, microservices, and NestJS apps
🆕 What's New
🎉 New in this version
- 🆕 ICO support — generate icons directly from PDFs
- 🆕 TIFF support — high-quality image output for professional workflows
⚡ Features
⚡ Blazing Fast — Powered by WASM for high performance
📦 Zero Dependencies — No external binaries required
🖼 Multiple Formats Supported:
- PNG
- JPEG
- BMP
- PPM
- 🆕 ICO
- 🆕 TIFF
🧩 Flexible API — Convert single, multiple, or all pages
🦅 NestJS Ready — First-class integration
🎨 Customisable Output — DPI, quality, and page selection
💠 Fully Typed — Built with TypeScript
📦 Installation
npm install pdf-image-converter🚀 Quick Start
import { pdfConverter } from "pdf-image-converter";
import fs from "node:fs/promises";
async function convert() {
const pdfBuffer = await fs.readFile("document.pdf");
const result = await pdfConverter.convertPage(pdfBuffer, 1, {
format: "png",
dpi: 300,
});
await fs.writeFile("page1.png", result.buffer);
}🔥 Advanced Usage
import { PdfConverter } from "pdf-image-converter";
const converter = new PdfConverter({
dpi: 200,
format: "jpeg",
});
async function convertAll(pdfBuffer: Buffer) {
const pages = await converter.convertAll(pdfBuffer, {
quality: 85,
});
console.log(`Converted ${pages.length} pages`);
}
async function convertSpecific(pdfBuffer: Buffer) {
const results = await converter.convertPages(pdfBuffer, [1, 3, 5]);
}🧠 Supported Formats
const formats = pdfConverter.supportedFormats();
console.log(formats);Output:
png, jpeg, bmp, ppm, ico, tiff🏗 NestJS Integration
1. Import Module
import { Module } from "@nestjs/common";
import { PdfImageModule } from "pdf-image-converter/nestjs";
@Module({
imports: [
PdfImageModule.forRoot({
defaultDpi: 150,
defaultFormat: "png",
}),
],
})
export class AppModule {}2. Inject Service
import { Injectable } from "@nestjs/common";
import { PdfImageService } from "pdf-image-converter/nestjs";
@Injectable()
export class AppService {
constructor(private readonly pdfService: PdfImageService) {}
async processPdf(pdfBuffer: Buffer) {
const totalPages = await this.pdfService.getPageCount(pdfBuffer);
return this.pdfService.convertAll(pdfBuffer);
}
}📚 API Overview
PdfConverter
convertPage(pdf, page, options)convertAll(pdf, options)convertPages(pdf, pages, options)getPageCount(pdf)supportedFormats()
⚙️ Options
| Option | Type | Description | | ------- | ------ | ------------------------------ | | format | string | png, jpeg, bmp, ppm, ico, tiff | | dpi | number | Resolution (default: 150) | | quality | number | 1–100 (JPEG/PNG compression) |
💡 Use Cases
- 📄 Document preview generation
- 🖼 Thumbnail creation
- 📦 File processing pipelines
- 🧾 PDF-to-image APIs
- 🎯 Icon generation (ICO support!)
❤️ Contributing & Support
If this package helped you:
- ⭐ Star the repo
- 🐛 Report issues
- 💡 PRs & ideas are always welcome!
It helps more developers discover this package 🚀
📄 License
MIT © 2026
