Skip to content

dariogeorge21/pdf-gate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDF GATE

A minimal, polished Next.js 14 App Router app that converts every page of a PDF into a high-resolution PNG image (300 DPI) and bundles them into a downloadable ZIP archive.


Tech Stack

Layer Library
Framework Next.js 14 (App Router)
PDF → PNG pdfjs-dist + @napi-rs/canvas
ZIP bundling jszip
Styling CSS Modules (Soft UI / Minimalist)
Font DM Sans + DM Mono (Google Fonts)

Getting Started

Prerequisites

  • Node.js 18+
  • The renderer uses @napi-rs/canvas, which ships prebuilt binaries for common Linux and macOS targets.
  • If your platform falls back to source compilation, install the native build toolchain recommended by that package.

Install & Run

# 1. Install dependencies
npm install

# 2. Start the dev server
npm run dev

Open http://localhost:3000.

Build for Production

npm run build
npm start

Project Structure

pdf-to-img-converter/
├── app/
│   ├── globals.css          # CSS custom properties + resets
│   ├── layout.tsx           # Root layout (Google Fonts, metadata)
│   ├── page.tsx             # Main UI (drag-drop, preview, download)
│   ├── page.module.css      # Scoped CSS Modules
│   └── api/
│       └── convert/
│           └── route.ts     # POST handler → PDF→PNG→ZIP pipeline
├── next.config.js           # serverComponentsExternalPackages for canvas
├── package.json
└── tsconfig.json

API Reference

POST /api/convert

Request: multipart/form-data with a file field (PDF, max 10 MB).

Response: Binary ZIP archive (application/zip).

Header Description
Content-Type application/zip
Content-Disposition attachment; filename="<name>_images.zip"
X-Page-Count Number of pages converted

Error responses are JSON: { "error": "..." }.


Limitations

  • Max file size: 10 MB
  • Only PDF files are accepted
  • Serverless timeout: 60 s (adjust maxDuration in the route file)
  • PDF rendering uses a native canvas backend bundled with the application dependencies

Deployment Notes

Vercel

Add a vercel.json to increase the function timeout if needed:

{
  "functions": {
    "app/api/convert/route.ts": {
      "maxDuration": 60
    }
  }
}

Docker

If deploying in a container, make sure the image can install native Node modules during npm install.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors