A blazingly fast, feature-rich PDF generation engine built with modern Node.js
Transform any content into beautiful PDFs with just one command. From simple text to complex JSON structures, this engine handles it all with precision and style.
Built from the ground up with developer experience in mind, this isn't just another PDF converter. It's a complete solution that bridges the gap between content and presentation.
π― Smart Auto-Detection - Automatically detects content type
β‘ Lightning Fast - Powered by Puppeteer's Chrome engine
π¨ Beautiful Output - Professional styling out of the box
π Web Ready - Full REST API + Interactive web interface
π³ Deploy Anywhere - Docker-ready for instant deployment
| Feature | Description | Status |
|---|---|---|
| Multi-Format Support | Text, HTML, JSON, Markdown - we've got you covered | β |
| Intelligent JSON Rendering | Structured, Table, or Raw display modes | β |
| Web Interface | Drag-and-drop file conversion with live preview | β |
| REST API | Full-featured API for integration | β |
| CLI Power | Command-line interface for automation | β |
| Smart Templates | Customizable HTML templates with CSS styling | β |
| Batch Processing | Convert multiple files at once | β |
| Docker Ready | One-command deployment anywhere | β |
| Auto-Detection | Automatically detects input format | β |
| Production Ready | Built for scale with proper error handling | β |
Perfect for documentation, notes, and simple content.
Simple text content that gets converted to a clean PDF format.
Multi-line support with automatic formatting.
Full HTML support with CSS styling and complex layouts.
<h1>Rich Content</h1>
<p>Complete HTML support with <strong>styling</strong></p>
<table>
<tr><td>Tables</td><td>β
Supported</td></tr>
</table>- Structured: Clean, hierarchical view
- Table: Automatic table generation for arrays
- Raw: Pretty-printed JSON with syntax highlighting
{
"title": "Smart JSON Rendering",
"features": ["Auto-formatting", "Multiple views", "Syntax highlighting"],
"data": [
{"name": "Alice", "role": "Developer"},
{"name": "Bob", "role": "Designer"}
]
}Full CommonMark support with extensions.
# Professional Documents
## With **rich** formatting
- Lists and tables
- Code blocks with syntax highlighting
- Links and images
> Blockquotes and more!# Clone this masterpiece
git clone https://github.com/your-username/pdf-generation-engine.git
cd pdf-generation-engine
# Install dependencies
npm install
# Ready to rock! πΈ# Convert any file instantly
npm start -- --input document.md --output beautiful.pdf --type markdown
# Convert text on the fly
npm start -- --text "Transform this!" --output magic.pdf --type text
# Launch the web interface
npm start -- --server
# Visit http://localhost:3000 for the interactive interface# Basic conversion
npm start -- --input README.md --output docs.pdf --type markdown
# Advanced options with JSON formatting
npm start -- --input data.json --output report.pdf --type json --format table
# Custom PDF settings
npm start -- --input content.html --output styled.pdf --type html --format A4
# Batch processing
npm start -- --input "*.md" --output batch/ --type markdownThe interactive web interface provides:
- π Drag & Drop file upload
- ποΈ Live format selection (JSON: Structured/Table/Raw)
- π Instant preview before conversion
- β¬οΈ One-click download
Start the server and visit http://localhost:3000:
npm start -- --serverOur RESTful API is perfect for integrating into your applications:
const response = await fetch('http://localhost:3000/api/convert', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
content: '# Hello World\nThis is **markdown**!',
type: 'markdown',
options: {
filename: 'awesome.pdf',
format: 'A4'
}
})
});
const pdfBlob = await response.blob();const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('type', 'auto'); // Auto-detect format
formData.append('jsonFormat', 'table'); // For JSON files
const response = await fetch('http://localhost:3000/api/upload', {
method: 'POST',
body: formData
});Customize every aspect of your PDF generation with config.json:
{
"pdf": {
"format": "A4", // A4, A3, A5, Legal, Letter, Tabloid
"margin": {
"top": "1cm",
"right": "1cm",
"bottom": "1cm",
"left": "1cm"
},
"printBackground": true, // Include CSS backgrounds
"preferCSSPageSize": true, // Respect CSS page sizes
"displayHeaderFooter": false,
"headerTemplate": "",
"footerTemplate": ""
},
"server": {
"port": 3000,
"host": "0.0.0.0" // Bind to all interfaces
},
"templates": {
"default": "default.html", // Custom template path
"style": {
"theme": "professional", // professional, minimal, modern
"fontFamily": "Arial, sans-serif",
"fontSize": "12pt"
}
}
}Create your own HTML templates in src/templates/:
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: 'Helvetica Neue', sans-serif; }
.header { border-bottom: 2px solid #007acc; }
.content { margin: 20px 0; }
</style>
</head>
<body>
<div class="header">{{title}}</div>
<div class="content">{{content}}</div>
</body>
</html>Built with modern Node.js and ES modules for maximum performance and maintainability.
π¦ PDF Generation Engine
βββ π src/
β βββ π index.js # Main application entry point
β βββ π converters/ # Format-specific converters
β β βββ textConverter.js # Plain text β HTML
β β βββ htmlConverter.js # HTML processing & validation
β β βββ jsonConverter.js # JSON β Formatted display
β β βββ markdownConverter.js # Markdown β HTML (CommonMark)
β βββ β‘ generators/ # PDF generation engine
β β βββ pdfGenerator.js # Puppeteer-powered PDF creation
β βββ π server/ # Web server & API
β β βββ app.js # Express server with REST API
β β βββ public/ # Web interface assets
β βββ π οΈ utils/ # Utility functions
β β βββ helpers.js # Config, validation, file operations
β βββ π¨ templates/ # HTML templates
β βββ default.html # Professional default template
βββ π examples/ # Sample files for testing
βββ π output/ # Generated PDF files
βββ π³ Dockerfile # Production deployment
βββ βοΈ config.json # Configuration file
βββ π README.md # This beautiful documentation
- π§ Converters: Modular design for easy extension
- β‘ PDF Generator: Puppeteer-based with Chrome rendering
- π Web Server: Express.js with CORS and file upload
- π οΈ Utilities: Smart content detection and validation
- π¨ Templates: Customizable HTML/CSS for beautiful output
Explore our examples/ directory for ready-to-use sample files:
Clean, professional text formatting with automatic line breaks
and paragraph spacing. Perfect for documentation and reports.
Rich HTML with tables, lists, and styling that renders beautifully in PDF format.
{
"title": "Smart JSON Display",
"users": [
{"name": "Alice", "role": "Developer", "experience": "5 years"},
{"name": "Bob", "role": "Designer", "experience": "3 years"}
]
}Renders as beautiful tables when using --format table
---
title: Professional Markdown
author: Your Name
---
# Full CommonMark Support
## With syntax highlighting, tables, and more!
| Feature | Status |
|---------|--------|
| Headers | β
|
| Tables | β
|
| Code | β
|# Build the image
docker build -t pdf-engine .
# Run locally
docker run -p 3000:3000 pdf-engine
# Deploy to any cloud platform- Push to GitHub
- Connect to Render
- Deploy automatically with our Dockerfile
- Get a live URL instantly!
Why Render?
- β Free 750 hours/month
- β Perfect Puppeteer support
- β Auto-deploys from Git
- β HTTPS by default
This engine represents hours of careful engineering, optimization, and attention to detail. Every component is designed for:
- π Performance - Lightning-fast PDF generation
- π Reliability - Production-ready error handling
- π¨ Quality - Beautiful, professional output
- π§ Extensibility - Easy to customize and extend
MIT License - Feel free to use this in your own projects!
β Star this repo if it helped you create amazing PDFs! β
Built with β€οΈ and lots of β