Skip to content

This is a complete certificate generation system that automatically creates professional PDF certificates

License

Notifications You must be signed in to change notification settings

devag7/certificate_generator_py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽ“ Professional Certificate Generator

Created by devag7 (Dev Agarwalla)
Generate beautiful, professional certificates with QR codes in seconds!

Python 3.8+ License: MIT FFmpeg

โœจ What This Project Does

This is a complete certificate generation system that automatically creates professional PDF certificates with:

  • ๐Ÿ“ Custom text (names, courses, dates, etc.)
  • ๐Ÿ” QR codes for verification
  • ๐ŸŽจ Beautiful design using your template
  • โšก Fast processing (under 1 second per certificate)
  • ๐Ÿ“„ PDF output ready for printing or sharing

Perfect for schools, training centers, online courses, or any organization that issues certificates!

๐ŸŽฏ Quick Demo

Input:

{
    "user_name": "John Doe",
    "college": "Tech Academy", 
    "topic": "Python Programming",
    "certificate_id": "CERT-2024-001"
}

Output: Beautiful PDF certificate with QR code verification!

๐Ÿš€ Super Quick Start (3 Steps)

1๏ธโƒฃ Install Requirements

# macOS
brew install ffmpeg imagemagick

# Ubuntu/Linux
sudo apt install ffmpeg imagemagick

# Windows (with Chocolatey)
choco install ffmpeg imagemagick

2๏ธโƒฃ Setup Project

git clone https://github.com/devag7/certificate-generator.git
cd certificate-generator
pip install -r requirements.txt

3๏ธโƒฃ Generate Your First Certificate

python producer.py

That's it! Your certificate will be in the certificates/ folder! ๐ŸŽ‰

๐Ÿ“ Project Structure

certificate-generator/
โ”œโ”€โ”€ ๐Ÿ“œ producer.py          # Main script to generate certificates
โ”œโ”€โ”€ โš™๏ธ tasks.py             # Core generation logic  
โ”œโ”€โ”€ ๐Ÿ› ๏ธ utils.py             # Helper functions
โ”œโ”€โ”€ ๐Ÿงช test_suite.py        # Tests
โ”œโ”€โ”€ ๐Ÿ“‹ requirements.txt     # Dependencies
โ”œโ”€โ”€ ๐Ÿณ Dockerfile          # Docker setup
โ”œโ”€โ”€ ๐Ÿ“„ templates/           # Certificate template images
โ”œโ”€โ”€ ๐Ÿ”ค fonts/               # Font files
โ””โ”€โ”€ ๐Ÿ“‘ certificates/        # Generated certificates (created automatically)

๐ŸŽจ How to Use

Method 1: Simple Generation (Recommended for beginners)

  1. Edit the data in producer.py:
cert_data = {
    "user_name": "Your Name Here",        # Student/recipient name
    "college": "Your Institution",        # School/company name  
    "topic": "Course Name",               # What the certificate is for
    "certificate_id": "CERT-001",         # Unique ID
    "issued_at": "2024-06-10"            # Date issued
}
  1. Run the generator:
python producer.py
  1. Find your certificate in the certificates/ folder!

Method 2: Direct Python Usage

from tasks import generate_certificate

# Your certificate data
data = {
    "user_name": "Jane Smith",
    "college": "Digital University", 
    "topic": "Web Development",
    "certificate_id": "WEB-2024-001",
    "issued_at": "2024-06-10T15:30:00"
}

# Generate certificate
certificate_path = generate_certificate(data)
print(f"Certificate created: {certificate_path}")

Method 3: Batch Generation (Multiple Certificates)

from tasks import generate_certificate

# List of students
students = [
    {"user_name": "Alice Johnson", "college": "Tech Academy", "topic": "Python Basics"},
    {"user_name": "Bob Smith", "college": "Code School", "topic": "Data Science"},
    {"user_name": "Carol Williams", "college": "Dev Institute", "topic": "Web Design"}
]

# Generate certificates for all students
for student in students:
    student["certificate_id"] = f"BATCH-{student['user_name'].replace(' ', '-')}"
    student["issued_at"] = "2024-06-10"
    
    certificate_path = generate_certificate(student)
    print(f"โœ… Generated: {certificate_path}")

๐ŸŽจ Customize Your Certificates

Change the Template

  1. Add your template image to the templates/ folder
  2. Update the path in tasks.py:
TEMPLATE_PATH = BASE_DIR / "templates" / "your_template.jpg"  # Change this line

Adjust Text Positions

Edit the text positions in tasks.py (around line 100):

filter_chain = (
    f"drawtext=text='{esc['name']}':x=90:y=880:fontsize=50:"      # Name position
    f"fontfile='{font_path}':fontcolor=black,"
    f"drawtext=text='{esc['college']}':x=90:y=1050:fontsize=45:"  # College position  
    f"fontfile='{font_path}':fontcolor=black,"
    # Adjust x,y coordinates for your template
)

Use Different Fonts

  1. Add .ttf font files to the fonts/ folder
  2. Update font path in tasks.py:
FONT_PATH = BASE_DIR / "fonts" / "your_font.ttf"  # Change this line

๐Ÿ”ง Advanced Features

Async Processing (For High Volume)

Start Redis and Celery (for processing many certificates):

# Terminal 1: Start Redis
redis-server

# Terminal 2: Start Celery worker  
celery -A tasks worker --loglevel=info

# Terminal 3: Generate certificates
python producer.py  # Will now use async processing

Environment Configuration

Create .env file for custom settings:

# Copy from .env.example and modify
ASYNC_MODE=false           # true for async processing
FONT_SIZE_NAME=50         # Name text size
FONT_SIZE_COLLEGE=45      # College text size  
OUTPUT_DIR=certificates   # Where to save certificates

Docker Deployment

# Build and run with Docker
docker-compose up -d

# Generate certificates via API
curl -X POST http://localhost:8000/generate \
  -H "Content-Type: application/json" \
  -d '{"user_name":"Test User","college":"Test College","topic":"Test Course"}'

๐Ÿงช Testing

# Run all tests
python test_suite.py

# Check system health  
python -c "from tasks import health_check; import json; print(json.dumps(health_check(), indent=2))"

๐Ÿ› Troubleshooting

"FFmpeg not found"

# Install FFmpeg
brew install ffmpeg        # macOS
sudo apt install ffmpeg   # Ubuntu
choco install ffmpeg      # Windows

"ImageMagick not found"

# Install ImageMagick
brew install imagemagick        # macOS
sudo apt install imagemagick   # Ubuntu
choco install imagemagick      # Windows

"Template not found"

  • Make sure certificate_template.jpg exists in templates/ folder
  • Check the file path in tasks.py

"Font not found"

  • Ensure your font file exists in fonts/ folder
  • The system will use default font if custom font is missing

PDF Conversion Issues (Ubuntu)

# Fix ImageMagick policy for PDF
sudo sed -i 's/rights="none" pattern="PDF"/rights="read|write" pattern="PDF"/' /etc/ImageMagick-6/policy.xml

๐Ÿ“Š Performance

  • โšก Generation time: ~200ms per certificate
  • ๐Ÿ“„ Output size: ~200KB per PDF
  • ๐Ÿ” QR code: High resolution, fast scanning
  • ๐Ÿ’พ Memory usage: Minimal (< 50MB)

๐Ÿ” How It Works

  1. Input Validation - Checks that all required data is provided
  2. QR Code Generation - Creates verification QR code with certificate ID
  3. Text Overlay - Uses FFmpeg to add text to certificate template
  4. PDF Conversion - Converts to PDF using ImageMagick
  5. File Optimization - Compresses output for smaller file size
  6. Cleanup - Removes temporary files

๐ŸŽฏ Use Cases

  • ๐ŸŽ“ Educational institutions - Course completion certificates
  • ๐Ÿข Corporate training - Employee certification
  • ๐ŸŒ Online courses - MOOC/e-learning certificates
  • ๐Ÿ† Events & competitions - Award certificates
  • ๐Ÿค Professional development - Skill certification

๐Ÿ”ฎ What You Can Build

  • Certificate API - REST API for certificate generation
  • Web interface - Upload CSV, generate bulk certificates
  • Integration - Add to existing LMS/education platforms
  • Verification system - QR code verification portal
  • White-label solution - Customize for clients

๐Ÿค Contributing

Found a bug? Have an idea? Contributions welcome!

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/awesome-feature
  3. Make changes and test: python test_suite.py
  4. Commit: git commit -m 'Add awesome feature'
  5. Push: git push origin feature/awesome-feature
  6. Create Pull Request

๐Ÿ“ž Need Help?

๐Ÿ“„ License

MIT License - feel free to use in your projects!

๐Ÿ™ Credits

Created with โค๏ธ by devag7 (Dev Agarwalla)

Special thanks to:

  • FFmpeg team for video/image processing
  • ImageMagick for PDF conversion
  • Celery for async task processing
  • Python community for amazing libraries

โญ Found this useful? Give it a star! โญ

๐Ÿš€ Ready to generate your first certificate? Run python producer.py now! ๐Ÿš€

About

This is a complete certificate generation system that automatically creates professional PDF certificates

Resources

License

Stars

Watchers

Forks