Professional PowerPoint presentations without Node.js dependencies
A comprehensive, pure-Python solution for creating visually stunning PowerPoint presentations that rivals Node.js-based tools. Features advanced HTML-to-PowerPoint conversion, beautiful chart generation, gradient rendering, and modern template designs.
- HTML to PowerPoint Conversion - Convert HTML/CSS to PowerPoint with precise positioning and styling
- Beautiful Gradient Support - Render CSS gradients (linear, radial, multi-color) as high-quality images
- Professional Charts - Matplotlib-powered charts with 6 gorgeous color schemes
- Modern Templates - Pre-built professional slide layouts
- Advanced Image Processing - Create icons, gradients, and visual effects
- Template Management - Work with existing templates, extract content, and manage slides
- Validation & Utilities - Comprehensive validation, thumbnail generation, and helper functions
pip install -r requirements.txtfrom html2pptx import create_presentation_from_html
slides = [
"""
<div style="width: 720pt; height: 405pt; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);">
<h1 style="position: absolute; left: 50pt; top: 150pt; width: 620pt; color: white;
font-size: 54pt; font-family: Arial; text-align: center;">
Beautiful Presentation
</h1>
</div>
"""
]
create_presentation_from_html(slides, 'output.pptx', '16:9')Convert HTML with CSS styling to PowerPoint slides.
Features:
- CSS parsing and application
- Precise positioning with absolute/relative layouts
- Linear and radial gradient rendering
- Web-safe font support
- Border, background, and text styling
- Lists, images, and complex layouts
Example:
from html2pptx import HTML2PPTX
converter = HTML2PPTX(aspect_ratio='16:9')
converter.add_slide_from_html(html_content)
converter.save('presentation.pptx')Supported CSS Properties:
position,left,top,width,heightbackground,background-color(including gradients)color,font-family,font-size,font-weight,font-styletext-align,borderlinear-gradient,radial-gradient
Create stunning charts with matplotlib integration.
Chart Types:
- Bar charts (clustered and stacked)
- Line charts (with/without markers)
- Pie charts
- Area charts
- Scatter plots
Color Schemes:
professional- Classic business colorsvibrant- Bold, energetic colorspastel- Soft, gentle colorscorporate- Conservative blues and graysmodern- Contemporary gradient-ready colors
Example:
from pptx_charts import ChartGenerator
from pptx import Presentation
prs = Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[6])
ChartGenerator.add_matplotlib_chart(
slide, 1, 1, 8, 4,
ChartGenerator.create_beautiful_bar_chart,
categories=['Q1', 'Q2', 'Q3', 'Q4'],
data_series=[
{'name': 'Sales', 'values': [100, 120, 140, 160]},
{'name': 'Revenue', 'values': [90, 110, 130, 150]}
],
title='Quarterly Performance',
color_scheme='modern'
)
prs.save('charts.pptx')Create and manipulate images for PowerPoint.
Capabilities:
- Gradient generation (linear, radial, multi-color)
- Icon creation (circle, square, triangle, star, checkmark, arrow)
- Drop shadows
- Rounded rectangles
- Text rendering
- Image optimization
Example:
from pptx_images import ImageProcessor
processor = ImageProcessor()
# Create gradient
gradient = processor.create_gradient_image(800, 600, (102, 126, 234), (118, 75, 162), 45)
gradient.save('gradient.png')
# Create icon
icon = processor.create_icon('star', 200, (79, 70, 229))
icon.save('star_icon.png')
# Multi-color gradient
multi_grad = processor.create_multi_color_gradient(
800, 600,
[(102, 126, 234), (118, 75, 162), (237, 100, 166), (255, 198, 93)]
)
multi_grad.save('multi_gradient.png')Pre-built professional slide templates.
Template Types:
- Title slides with gradients
- Section divider slides
- Content slides (1, 2, or 3 column layouts)
- Image slides with captions
- Quote slides
- Custom layouts
Example:
from pptx_templates import ModernTemplates
from pptx import Presentation
from pptx.util import Inches
prs = Presentation()
prs.slide_width = Inches(10)
prs.slide_height = Inches(5.625)
color = (79, 70, 229) # Modern indigo
ModernTemplates.create_title_slide(
prs, "My Presentation", "Subtitle Here", color
)
ModernTemplates.create_content_slide(
prs, "Key Points",
["Point 1", "Point 2", "Point 3", "Point 4"],
color, 'two_column'
)
ModernTemplates.create_quote_slide(
prs, "Inspiring quote here", "Author Name", color
)
prs.save('modern_presentation.pptx')Template Management:
from pptx_templates import TemplateManager
# Work with existing template
manager = TemplateManager('template.pptx')
# Get inventory of all slides
inventory = manager.get_slide_inventory()
manager.save_inventory('inventory.json')
# Replace text across slides
manager.replace_text({
'{{COMPANY}}': 'Acme Corp',
'{{DATE}}': '2024-01-15'
})
# Duplicate slides
new_slide_idx = manager.duplicate_slide(0)
manager.save('updated_presentation.pptx')Helper functions for PowerPoint operations.
Features:
- Presentation validation
- File size checking
- Thumbnail generation
- Slide grid creation
- Text extraction
- Statistics gathering
- Slide numbering
- Presentation merging
Example:
from pptx_utils import Validator, ThumbnailGenerator, PPTXHelper
# Validate presentation
validation = Validator.validate_presentation('presentation.pptx')
print(f"Valid: {validation['valid']}")
print(f"Errors: {validation['errors']}")
print(f"Warnings: {validation['warnings']}")
# Check file size
size_info = Validator.check_file_size('presentation.pptx', max_size_mb=50)
print(f"File size: {size_info['file_size_mb']} MB")
# Generate thumbnails
thumbnails = ThumbnailGenerator.generate_slide_thumbnails(
'presentation.pptx', 'output_dir'
)
# Create slide grid
grid_path = ThumbnailGenerator.create_slide_grid(
'presentation.pptx', 'grid.png', columns=3
)
# Get statistics
stats = PPTXHelper.get_presentation_stats('presentation.pptx')
print(stats)
# Extract all text
text_data = PPTXHelper.extract_text('presentation.pptx')
# Add slide numbers
PPTXHelper.add_slide_numbers('input.pptx', 'output.pptx', start_number=1)Run the comprehensive examples:
python examples.pyThis generates 5 example presentations demonstrating all features:
- example_1_html.pptx - HTML conversion with beautiful gradients
- example_2_charts.pptx - Professional charts and data visualization
- example_3_templates.pptx - Modern template designs
- example_4_images.pptx - Advanced image processing and effects
- example_5_complete.pptx - Complete business presentation
- Use web-safe fonts: Arial, Helvetica, Times New Roman, Georgia, Courier New, Verdana, Tahoma, Trebuchet MS
- Always wrap text: Use
<p>,<h1>-<h6>,<ul>, or<ol>tags - Use points (pt) for dimensions: Matches PowerPoint's native units
- Gradient performance: Pre-render complex gradients for better performance
- Limit data series: 3-5 series for bar/line charts
- Use consistent color schemes: Stick to one scheme per presentation
- Add context: Always include titles and labels
- Optimize size: Use appropriate chart dimensions for readability
- Image size: Keep images under 1MB when possible
- Gradient resolution: Use 96-150 DPI for gradients
- Slide count: Break large presentations into multiple files
- Validation: Always validate after creation
| Feature | Python Version | Node.js Version |
|---|---|---|
| HTML to PPTX | β Full support | β Full support |
| CSS Gradients | β Rendered as images | β Native rendering |
| Charts | β Matplotlib (beautiful) | β PptxGenJS |
| Image Processing | β Pillow | β Sharp |
| Template Management | β Full support | β Full support |
| Cross-platform | β Pure Python | |
| Dependencies | 10 Python packages | 15+ npm packages |
| Performance | Fast | Very fast |
| Learning Curve | Low (Python) | Medium (Node.js) |
python-pptx>=0.6.21
Pillow>=10.0.0
matplotlib>=3.7.0
beautifulsoup4>=4.12.0
lxml>=4.9.0
cairosvg>=2.7.0
cssselect>=1.2.0
tinycss2>=1.2.0
reportlab>=4.0.0
svglib>=1.5.0
from pptx_charts import ChartGenerator
# Add custom color scheme
ChartGenerator.COLOR_SCHEMES['mycustom'] = [
(255, 99, 71), # Tomato
(60, 179, 113), # Medium Sea Green
(106, 90, 205), # Slate Blue
(255, 215, 0), # Gold
]
# Use it
ChartGenerator.add_matplotlib_chart(
slide, 1, 1, 8, 4,
ChartGenerator.create_beautiful_bar_chart,
categories=categories,
data_series=data_series,
color_scheme='mycustom'
)from html2pptx import HTML2PPTX
html = """
<div style="width: 720pt; height: 405pt; background: white;">
<!-- Header -->
<div style="position: absolute; left: 0; top: 0; width: 720pt; height: 60pt;
background: linear-gradient(90deg, #4f46e5 0%, #7c3aed 100%);"></div>
<!-- Title -->
<h1 style="position: absolute; left: 30pt; top: 10pt; color: white;
font-size: 36pt; font-family: Arial;">Complex Layout</h1>
<!-- Left column -->
<div style="position: absolute; left: 30pt; top: 80pt; width: 320pt; height: 300pt;
background: #f3f4f6; border: 2px solid #e5e7eb;">
<h2 style="position: absolute; left: 20pt; top: 20pt; font-size: 24pt;">Column 1</h2>
<p style="position: absolute; left: 20pt; top: 60pt; width: 280pt; font-size: 16pt;">
Content here
</p>
</div>
<!-- Right column -->
<div style="position: absolute; left: 370pt; top: 80pt; width: 320pt; height: 300pt;
background: #f3f4f6; border: 2px solid #e5e7eb;">
<h2 style="position: absolute; left: 20pt; top: 20pt; font-size: 24pt;">Column 2</h2>
<p style="position: absolute; left: 20pt; top: 60pt; width: 280pt; font-size: 16pt;">
More content
</p>
</div>
</div>
"""
converter = HTML2PPTX()
converter.add_slide_from_html(html)
converter.save('complex_layout.pptx')Issue: Gradients look pixelated
- Solution: Increase gradient image resolution (multiply width/height by 1.5-2)
Issue: Fonts not displaying correctly
- Solution: Use only web-safe fonts from the supported list
Issue: Text overflow
- Solution: Adjust text box dimensions or reduce font size
Issue: Large file size
- Solution: Optimize images before adding, reduce gradient resolution
Issue: Charts not displaying
- Solution: Ensure matplotlib backend is set to 'Agg'
This project is part of the Algorithms repository.
Contributions welcome! This is a pure-Python implementation designed to match and exceed Node.js PowerPoint capabilities.
Unlike the Node.js version that requires Chromium, Sharp, and multiple dependencies, this Python implementation:
- Pure Python - No external binaries required
- Beautiful by Default - Professional color schemes and modern templates
- Powerful Charts - Matplotlib integration for publication-quality visualizations
- Gradient Mastery - Render any CSS gradient perfectly
- Easy to Deploy - Simple pip install, works anywhere Python runs
- Well Documented - Comprehensive examples and clear API
This toolkit enables you to:
- Create investor pitch decks with stunning visuals
- Generate automated reports with dynamic charts
- Build template-based presentations at scale
- Convert HTML slides to PowerPoint for offline use
- Design modern, gradient-rich presentations
Ready to create amazing PowerPoint presentations with Python? Start with examples.py!