Skip to content

skidzo/autobasedoc

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AutoBaseDoc - Professional PDF Automation

Automated creation of professional PDF documents with advanced layout features using ReportLab and Matplotlib integration.

Documentation Status Current Version PyPI Python Version License

AutoBaseDoc is a Python library that extends ReportLab's capabilities to provide automated PDF document generation with sophisticated layout management, matplotlib integration, and professional styling. It's designed for creating reports, documentation, and complex multi-page documents with minimal code.

✨ Key Features

🎨 Flexible Layout System

  • Portrait and Landscape: Seamless switching between orientations
  • Multi-column Layouts: Configurable column structures with automatic flow
  • Frame Management: Advanced frame handling with automatic sizing
  • Mixed Formats: Combine different layouts within a single document

πŸ“Š Matplotlib Integration

  • Direct Plot Embedding: Convert matplotlib figures to PDF flowables
  • Automatic Scaling: Intelligent image resizing to fit frames
  • Vector Graphics: Preserve plot quality with PDF vector support
  • Consistent Styling: Unified font and color management

πŸ“‘ Automatic Navigation

  • Table of Contents: Auto-generated with clickable links
  • PDF Bookmarks: Hierarchical navigation structure
  • Cross-references: Internal document linking
  • Page Numbering: Flexible header/footer management

✨ Professional Styling

  • Predefined Styles: Ready-to-use paragraph and heading styles
  • Custom Fonts: TTF font support with automatic registration
  • Color Management: Consistent color schemes
  • Template System: Reusable document templates

πŸš€ Installation

Standard Installation

pip install autobasedoc

Development Installation

git clone https://github.com/NuCOS/autobasedoc.git
cd autobasedoc
pip install -e .

Environment Setup Script

If you want to create a local virtual environment with all dependencies, you can run the helper script:

./setup_env.sh

Requirements

  • Python 3.6+
  • ReportLab 3.5+
  • Matplotlib 3.0+
  • Additional dependencies: svglib, pdfrw

πŸ“– Quick Start

Basic Document Creation

import autobasedoc.autorpt as ar

# Create document with predefined templates
doc = ar.AutoDocTemplate(
    "my_report.pdf",
    onFirstPage=(ar.drawFirstPortrait, 0),
    onLaterPages=(ar.drawLaterPortrait, 0),
    title="My Professional Report"
)

# Initialize styles
styles = ar.Styles()

# Build content
content = []
content.append(ar.Paragraph("Executive Summary", styles.title))
content.append(ar.doTableOfContents())  # Auto-generated TOC
content.append(ar.Paragraph("Introduction", styles.h1))
content.append(ar.Paragraph("This is the content...", styles.normal))

# Generate PDF
doc.multiBuild(content)

Multi-column Layout

# Two-column landscape document
doc = ar.AutoDocTemplate(
    "newsletter.pdf",
    onFirstPage=(ar.drawFirstLandscape, 1),
    onLaterPages=(ar.drawLaterLandscape, 2),  # 2 columns
    pagesize=ar.landscape(ar.A4)
)

Headers and Footers

# Add professional headers and footers
doc.addPageInfo(typ="header", pos="l", text="Company Name")
doc.addPageInfo(typ="header", pos="r", text="Report Title")
doc.addPageInfo(typ="footer", pos="c", text="Page ", addPageNumber=True)
doc.addPageInfo(typ="footer", pos="r", text="Confidential")

Matplotlib Integration

import autobasedoc.autoplot as ap
import matplotlib.pyplot as plt

# Create a matplotlib figure
@ap.pdfplot()  # Decorator converts to PDF flowable
def create_chart():
    plt.figure(figsize=(8, 6))
    plt.plot([1, 2, 3, 4], [1, 4, 2, 3])
    plt.title("Sample Chart")
    plt.xlabel("X Axis")
    plt.ylabel("Y Axis")
    return plt.gcf()

# Add to document
chart = create_chart()
content.append(chart)

πŸ“ Project Structure

autobasedoc/
β”œβ”€β”€ autobasedoc/
β”‚   β”œβ”€β”€ __init__.py          # Package initialization
β”‚   β”œβ”€β”€ autorpt.py           # Core document templates
β”‚   β”œβ”€β”€ autoplot.py          # Matplotlib integration
β”‚   β”œβ”€β”€ styles.py            # Styling system
β”‚   β”œβ”€β”€ pageinfo.py          # Header/footer management
β”‚   β”œβ”€β”€ fonts.py             # Font management
β”‚   β”œβ”€β”€ styledtable.py       # Advanced table layouts
β”‚   β”œβ”€β”€ tableofcontents.py   # TOC generation
β”‚   └── fonts/               # Bundled fonts
β”œβ”€β”€ tests/                   # Test suite and examples
β”œβ”€β”€ sphinx_doc/                    # Documentation source

🎯 Use Cases

Business Reports

  • Financial statements with charts and tables
  • Executive dashboards
  • Performance reports with automated data visualization

Technical Documentation

  • API documentation with code examples
  • Research papers with matplotlib plots
  • User manuals with mixed layouts

Academic Publications

  • Thesis documents with automatic formatting
  • Conference papers with figure management
  • Lab reports with data visualization

πŸ”§ Advanced Features

Custom Page Templates

def custom_page_template(canv, doc):
    """Custom page template with company branding"""
    # Add logo, watermarks, custom headers
    canv.drawImage("logo.png", 50, 750, width=100, height=50)
    # Custom frame configuration
    ar.addPlugin(canv, doc, frame="Custom")

doc = ar.AutoDocTemplate(
    "branded_report.pdf",
    onFirstPage=(custom_page_template, 0)
)

Dynamic Content

# Conditional page breaks
content.append(ar.PageBreak())

# Automatic figure numbering
content.append(ar.doImage(chart, doc, "Sales Chart", styles))

# Keep elements together
content.append(ar.KeepTogether([heading, table]))

Table Styling

from autobasedoc.styledtable import StyledTable

# Create styled table with automatic formatting
table = StyledTable([
    ["Product", "Q1", "Q2", "Q3", "Q4"],
    ["Widget A", "100", "120", "110", "130"],
    ["Widget B", "80", "90", "95", "105"]
])
table.setTableStyle("grid")  # Predefined styles
content.append(table)

Splitting Large Tables

# Automatically break a long table into manageable pieces
first, second = table.split_table_iterative(frameInfo, available_height)
story.extend([first.as_flowable, PageBreak(), second.as_flowable])

πŸ“š Documentation

  • Full Documentation: http://autobasedoc.readthedocs.io/
  • API Reference: Comprehensive function and class documentation
  • Examples Gallery: Visual examples of different layouts
  • Tutorials: Step-by-step guides for common tasks

πŸ§ͺ Testing

Run Test Suite

# Using pytest
pytest tests/

# Using nose2
nose2

# Run specific test file
python tests/test_autoreport.py

Test Coverage

# Generate coverage report
pytest --cov=autobasedoc tests/

Example Scripts

# Run basic example
python tests/example.py

# Run advanced document example
python tests/example_document.py

🀝 Contributing

We welcome contributions! Please see our contributing guidelines:

Development Setup

git clone https://github.com/NuCOS/autobasedoc.git
cd autobasedoc
pip install -e ".[dev]"  # Install with development dependencies

Code Standards

  • Follow PEP 8 style guidelines
  • Add type hints for new functions
  • Include docstrings in NumPy format
  • Write tests for new features

Contribution Process

  1. Fork the repository
  2. Create a 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

πŸ“‹ Changelog

Version 1.1.10 (Current)

  • Enhanced matplotlib integration
  • Improved table styling
  • Bug fixes in frame management

Version 1.1.x

  • Multi-column layout support
  • Advanced header/footer system
  • Custom font management

See CHANGELOG.md for complete version history.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

Third-party Licenses

  • ReportLab: BSD License
  • Matplotlib: PSF License
  • See individual package documentation for complete license information

πŸ†˜ Support

Getting Help

Commercial Support

For commercial support and custom development, contact: [email protected]

πŸ‘₯ Authors and Acknowledgments

  • Johannes Eckstein - @eckjoh2 - Lead Developer
  • Oliver Braun - Core Contributor

Special Thanks

  • ReportLab team for the excellent PDF library
  • Matplotlib community for visualization tools
  • Contributors and users providing feedback and improvements

πŸ”— Links


AutoBaseDoc - Making professional PDF generation simple and powerful.

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.8%
  • Other 1.2%