Skip to content

mahmoodhamdi/Markdown-to-PDF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Markdown to PDF Converter

Version Tests License

A production-ready Markdown to PDF converter web application built with Next.js 14, TypeScript, and Tailwind CSS. Features a freemium model with user authentication, team management, and enterprise SSO support.

Editor Screenshot

Features

Core Features

  • Live Preview - See changes in real-time as you type
  • 8 Document Themes - GitHub, Academic, Minimal, Dark, Professional, Elegant, Modern, Newsletter
  • Syntax Highlighting - Support for 20+ programming languages
  • Math Equations - LaTeX/KaTeX support
  • Mermaid Diagrams - Flowcharts, sequence diagrams, and more
  • Batch Conversion - Convert multiple files at once
  • 15+ Document Templates - Resume, Thesis, README, Meeting Notes, and more
  • Bilingual Support - English and Arabic with full RTL support
  • Responsive Design - Works on mobile, tablet, and desktop
  • Accessible - WCAG 2.1 AA compliant with keyboard navigation
  • Docker Support - Easy deployment with Docker
  • REST API - Programmatic access to conversion features

Premium Features

  • User Authentication - GitHub, Google, and email login
  • API Key Authentication - Programmatic access with rate limiting
  • Cloud Storage - Save and manage documents in the cloud
  • Custom CSS - Style your documents with custom CSS
  • Team Management - Collaborate with team members
  • Usage Analytics - Track conversion metrics with charts
  • Priority Rendering - Faster PDF generation with browser pooling
  • No Watermark - Remove watermark from PDFs

Enterprise Features

  • SSO Integration - SAML, OIDC, Azure AD, Okta, Google Workspace
  • Custom Domains - Use your own domain
  • SLA Guarantee - 99.9% uptime
  • Priority Support - Dedicated support channel
  • Self-Hosting - Deploy on your own infrastructure

Screenshots

Main Editor (English)

Editor English

Main Editor (Arabic RTL)

Editor Arabic

Theme Selection

Themes

Document Templates

Templates

Batch Conversion

Batch

API Documentation

API Docs

Mobile View

Mobile

Quick Start

Using Docker

docker pull mwmsoftware/markdown-to-pdf:latest
docker run -p 3000:3000 mwmsoftware/markdown-to-pdf

Manual Installation

git clone https://github.com/mahmoodhamdi/Markdown-to-PDF.git
cd Markdown-to-PDF
npm install
npm run dev

Open http://localhost:3000 in your browser.

Tech Stack

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS
  • Editor: Monaco Editor
  • Markdown: marked + highlight.js
  • PDF Generation: Puppeteer
  • Math: KaTeX
  • Diagrams: Mermaid
  • State Management: Zustand
  • Internationalization: next-intl
  • Testing: Vitest + Playwright (1500+ tests)
  • UI Components: Radix UI
  • Authentication: NextAuth.js
  • Database: MongoDB (Mongoose)
  • Storage: Firebase Storage
  • Payments: Multi-gateway (Stripe, Paymob, PayTabs, Paddle)

API Documentation

Authentication

API endpoints support two authentication methods:

Session-based (Web App)

  • Automatic via cookies for logged-in users

API Key (Programmatic)

curl -X POST https://your-domain.com/api/convert \
  -H "Authorization: Bearer mk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"markdown": "# Hello"}'

Convert to PDF

POST /api/convert
Content-Type: application/json

{
  "markdown": "# Hello World",
  "theme": "github",
  "pageSize": "A4",
  "orientation": "portrait"
}

Generate Preview

POST /api/preview
Content-Type: application/json

{
  "markdown": "# Hello World"
}

Batch Conversion

POST /api/convert/batch
Content-Type: application/json

{
  "files": [
    { "name": "doc1.md", "content": "# Document 1" },
    { "name": "doc2.md", "content": "# Document 2" }
  ],
  "theme": "github"
}

Get Available Themes

GET /api/themes

Get Document Templates

GET /api/templates

Health Check

GET /api/health

Checkout (Payment)

POST /api/checkout
Content-Type: application/json

{
  "plan": "pro",
  "billing": "monthly",
  "gateway": "stripe",      // Optional: stripe, paymob, paytabs, paddle
  "countryCode": "US"       // Optional: auto-selects gateway
}

Storage

# Upload file
POST /api/storage/upload

# List files
GET /api/storage/files

# Get storage quota
GET /api/storage/quota

Teams

# Create team
POST /api/teams

# Get team
GET /api/teams/[teamId]

# Manage members
POST /api/teams/[teamId]/members

Analytics

# Track event
POST /api/analytics/track

# Get summary
GET /api/analytics/summary

# Get history
GET /api/analytics/history

API Keys

# List API keys
GET /api/api-keys

# Create API key
POST /api/api-keys
{
  "name": "Production Key",
  "permissions": ["convert", "preview", "batch"]
}

# Revoke API key
DELETE /api/api-keys/[keyId]

Testing

# Run unit tests
npm run test

# Run unit tests in watch mode
npm run test:watch

# Run integration tests
npm run test:integration

# Run E2E tests
npm run test:e2e

Docker Deployment

Build and Run

# Build the Docker image
docker build -f docker/Dockerfile -t markdown-to-pdf .

# Run the container
docker run -p 3000:3000 markdown-to-pdf

Docker Compose

# Development
docker-compose -f docker/docker-compose.yml up

# Production
docker-compose -f docker/docker-compose.prod.yml up

Project Structure

src/
├── app/                    # Next.js App Router
│   ├── [locale]/          # Internationalized routes
│   │   ├── page.tsx       # Main editor page
│   │   ├── themes/        # Theme selection
│   │   ├── templates/     # Document templates
│   │   ├── batch/         # Batch conversion
│   │   └── api-docs/      # API documentation
│   └── api/               # API routes
│       ├── convert/       # PDF conversion
│       ├── checkout/      # Payment checkout
│       ├── webhooks/      # Payment webhooks (Stripe, Paymob, PayTabs, Paddle)
│       ├── storage/       # Cloud storage
│       ├── teams/         # Team management
│       ├── analytics/     # Usage analytics
│       └── sso/           # Enterprise SSO
├── components/            # React components
│   ├── editor/           # Editor components
│   ├── preview/          # Preview components
│   ├── converter/        # Conversion components
│   ├── layout/           # Layout components
│   └── ui/               # UI primitives
├── lib/                   # Core libraries
│   ├── markdown/         # Markdown parser
│   ├── pdf/              # PDF generator
│   ├── themes/           # Theme manager
│   ├── payments/         # Multi-gateway payments
│   ├── storage/          # Cloud storage service
│   ├── teams/            # Team management service
│   ├── analytics/        # Analytics service
│   ├── sso/              # SSO service
│   ├── db/               # MongoDB models & connection
│   └── plans/            # Pricing & rate limiting
├── stores/               # Zustand stores
├── messages/             # i18n translations
└── types/                # TypeScript types

Environment Variables

See CREDENTIALS.md for detailed setup instructions.

Variable Description Required
NEXTAUTH_URL Application URL Yes
NEXTAUTH_SECRET Session encryption key (32+ chars) Yes
MONGODB_URI MongoDB connection string Yes
FIREBASE_* Firebase Storage configuration Yes
GITHUB_ID/SECRET GitHub OAuth Optional
GOOGLE_CLIENT_ID/SECRET Google OAuth Optional
STRIPE_SECRET_KEY Stripe payments (Global) Optional
PAYMOB_SECRET_KEY Paymob payments (Egypt) Optional
PAYTABS_SERVER_KEY PayTabs payments (MENA) Optional
PADDLE_API_KEY Paddle payments (MoR) Optional
EMAIL_SERVER_* SMTP configuration Optional

Pricing Plans

Feature Free Pro ($5/mo) Team ($15/mo) Enterprise
Conversions/day 20 500 Unlimited Unlimited
File size 500KB 5MB 20MB 100MB
Themes 3 All All + Brand Custom
Cloud Storage - 1GB 10GB Unlimited
Team Members - - 5 Unlimited
SSO - - - Yes

Documentation

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License - see LICENSE for details.


Made with love by mahmoodhamdi

About

A production-ready Markdown to PDF converter with live preview, multiple themes, RTL support, and batch conversion. Built with Next.js 14, TypeScript, and Tailwind CSS.

Topics

Resources

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages