Skip to content

A Node.js backend to compress PDF files using Ghostscript with Docker support and Multer for file handling — ideal for reducing PDF file sizes efficiently.

Notifications You must be signed in to change notification settings

CoderAyushman/pdf-compressor-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📦 PDF Compressor – Node.js + Ghostscript + Docker

This project is a simple and efficient PDF compressor built with Node.js. It allows users to upload PDF files, compresses them using Ghostscript, and returns the compressed versions. It supports multiple file uploads, uses Multer for handling uploads, and Docker to run Ghostscript in a containerized environment.


🚀 Features

  • ✅ Compress PDF files using Ghostscript
  • ✅ Upload one or more PDF files
  • ✅ Returns downloadable compressed files
  • ✅ Uses Docker for cross-platform Ghostscript environment
  • ✅ Handles file uploads with Multer
  • ✅ Clean folder structure for easy maintenance

🛠 Tech Stack

  • Node.js
  • Express.js
  • Multer (File Upload Middleware)
  • Ghostscript (PDF compression)
  • Docker (optional Ghostscript container)
  • EJS (optional web interface)

📁 Folder Structure

pdf-compressor/
│ ├── upload/ # Original uploaded PDFs
├── compressed/ # Compressed output PDFs
├── components/
│ └── compressor.js # Ghostscript compression logic
├── views/
│ └── index.ejs # Simple HTML frontend (optional)
├── app.js # Main Express server
├── Dockerfile # Ghostscript environment setup
└── README.md # Project documentation


⚙️ Setup Instructions

1. Clone the Repository

git clone https://github.com/CoderAyushman/pdf-compressor-backend.git
cd pdf-compressor-backend

2. Install Dependencies

npm install

    Note: This project expects Ghostscript to be available via Docker or already configured in the system.

🐳 Docker Setup

To run Ghostscript in an isolated environment using Docker:
1. Build the Docker Image

docker build -t pdf-compressor-backend .

2. Run the Container

docker run -p 3200:3200 pdf-compressor-backend

🌐 Web Interface (EJS)

You can access a basic HTML frontend by visiting:

http://localhost:3200

About

A Node.js backend to compress PDF files using Ghostscript with Docker support and Multer for file handling — ideal for reducing PDF file sizes efficiently.

Topics

Resources

Stars

Watchers

Forks