A comprehensive, open-source PDF generation library with professional templates and brand management capabilities.
- High-quality PDF output using Playwright engine
- Async/await support for scalable applications
- Multiple document templates (documents, letters, reports, invoices, etc.)
- Custom page layouts and professional formatting
- Isolated brand configurations with custom styling
- Brand-specific templates and assets
- Logo, font, and image management
- Brand protection and access controls
- Jinja2-based template engine
- Responsive layouts for different page sizes
- Custom CSS injection and styling
- Extensible template architecture
- Pluggable storage interface for extensibility
- Local filesystem implementation included
- Async file operations
- Asset optimization and processing
pip install pdf-corefrom pdf_core import BrandManager, TemplateEngine, AsyncPDFGenerator
# Load brand configuration
brand_manager = BrandManager()
brand = brand_manager.load_brand("example_company")
# Process content with frontmatter
content = """---
title: "My Document"
author: "John Doe"
template: "document"
---
# Introduction
This is a sample document with professional styling.
## Features
- Professional templates
- Brand consistency
- High-quality output
"""
# Generate PDF
template_engine = TemplateEngine()
rendered = template_engine.render_template(content, brand)
async with AsyncPDFGenerator() as generator:
pdf_result = await generator.generate_pdf(rendered)
print(f"Generated: {pdf_result.pdf_path}")Create professional brand configurations using YAML:
brand:
name: "Your Company"
tagline: "Professional Excellence"
website: "https://yourcompany.com"
colors:
primary: "#1E3A8A" # Professional Blue
secondary: "#3B82F6" # Lighter Blue
accent: "#F59E0B" # Accent Color
typography:
primary_font: "Inter"
secondary_font: "Source Sans Pro"
assets:
logo: "assets/images/logo.svg"
stylesheet: "assets/company_style.css"Templates use Jinja2 syntax with full brand context:
<!DOCTYPE html>
<html>
<head>
<title>{{ title or "Document" }}</title>
<style>{{ stylesheet_content }}</style>
</head>
<body>
<header>
<img src="{{ brand.assets.logo }}" alt="{{ brand.name }}">
<h1>{{ title }}</h1>
{% if author %}<p>By {{ author }}</p>{% endif %}
</header>
<main>
{{ html_content }}
</main>
<footer>
{{ brand.name }}{% if brand.website %} β’ {{ brand.website }}{% endif %}
</footer>
</body>
</html>from pdf_core.services import LocalStorage, StorageInterface
# Use default local storage
brand_manager = BrandManager()
# Use custom storage location
local_storage = LocalStorage("/path/to/storage")
brand_manager = BrandManager(storage=local_storage)
# Extend with custom storage (implement StorageInterface)
class CustomStorage(StorageInterface):
async def upload_file(self, file_path, key, metadata=None):
# Your custom implementation
passPDF Core Library maintains high standards for reliability and quality:
- 96% Test Pass Rate (87/91 tests passing)
- 39% Overall Coverage with focused coverage on critical paths:
- PDFGenerator: 96% coverage
- TemplateEngine: 79% coverage
- BrandManager: 51% coverage
- Comprehensive Test Infrastructure with fixtures, helpers, and edge case testing
- Repository Coordination Testing ensuring compatibility across dependent libraries
- Continuous Integration with quality gates requiring >90% coverage for new features
# Install with development dependencies
pip install -e ".[dev]"
# Run tests with coverage
pytest --cov=src/pdf_core --cov-report=term-missing
# Run only core module tests
pytest tests/unit/core/ -v
# Type checking
mypy src/
# Code formatting
black src/ tests/
# Check test coverage for specific modules
pytest tests/unit/core/test_pdf_generator.py --cov=src/pdf_core.core.pdf_generator --cov-report=term-missingpdf-core/
βββ core/ # Core business logic
β βββ brand_manager.py # Brand configuration
β βββ template_engine.py # Template rendering
β βββ pdf_generator.
78D9
py # PDF generation (sync)
β βββ async_pdf_generator.py # PDF generation (async)
βββ services/ # Storage services
β βββ storage_abstraction.py # Storage interface and local implementation
βββ utils/ # Shared utilities
See the /docs/examples/ directory for:
- Basic PDF generation
- Custom brand setup
- Template development
- Library integration patterns
- Performance optimization
MIT License - see LICENSE file for details.
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Add tests for new functionality
- Ensure all tests pass (
pytest) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- π Documentation
- π Issue Tracker
- π¬ Discussions
- Comprehensive test coverage expansion (completed)
- Repository coordination testing (completed)
- Performance benchmarking and regression testing
- End-to-end integration testing with real browser instances
- WebP and AVIF image format support
- Template preview generation system
- Template marketplace integration
- Advanced typography controls
- Interactive PDF elements
- Multi-language template support