AutoBaseDoc
Automated PDF document generation on top of ReportLab with Matplotlib integration, reusable page templates, and helpers for tables, headers, footers, and table-of-contents handling.
Installation
pip install autobasedoc
Development setup:
git clone https://github.com/NuCOS/autobasedoc.git
cd autobasedoc
pip install -e .
pip install -e ".[test]"
Requirements:
- Python 3.7+
- ReportLab
- Matplotlib
svglib,pdfrw,img2pdf
Quick Start
import os
from autobasedoc import autorpt as ar
outname = os.path.join(os.getcwd(), "MinimalExample.pdf")
doc = ar.AutoDocTemplate(
outname,
onFirstPage=ar.onFirstPage,
onLaterPages=ar.onLaterPages,
onLaterSPages=ar.onLaterSPages,
leftMargin=0.5 * ar.cm,
rightMargin=0.5 * ar.cm,
topMargin=0.5 * ar.cm,
bottomMargin=0.5 * ar.cm,
)
styles = ar.Styles()
styles.registerStyles()
content = []
content.append(ar.Paragraph("Minimal Example Title", styles.title))
content.append(ar.PageBreak())
content.append(ar.Paragraph("Table Of Contents", styles.h1))
content.append(ar.doTableOfContents())
doc.multiBuild(content)
Matplotlib Integration
Use autoPdfImg when a plotting function should return a single ReportLab flowable:
from autobasedoc import autoplot as ap
@ap.autoPdfImg
def create_chart(canvaswidth=5):
fig, ax = ap.plt.subplots(figsize=(canvaswidth, canvaswidth))
ax.plot([1, 2, 3, 4], [1, 4, 2, 3])
ax.set_title("Sample Chart")
return fig
content.append(create_chart())
Use autoPdfImage when the plot and legend should be placed independently in the document:
@ap.autoPdfImage
def create_chart_with_legend(canvaswidth=5):
fig, ax = ap.plt.subplots(figsize=(canvaswidth, canvaswidth))
ax.plot([1, 2, 3, 4], [1, 4, 2, 3], label="series")
handles, labels = ax.get_legend_handles_labels()
legend_fig = ap.plt.figure(figsize=(canvaswidth, 0.4))
legend = legend_fig.legend(handles, labels, loc="center", frameon=False)
return fig, legend_fig, legend
plot_img, legend_img = create_chart_with_legend()
content.extend([legend_img, plot_img])
Table Layouts
For plain ReportLab tables, the standard ar.Table works well. For AutoBaseDoc-specific layout helpers, use StyledTable and finish with layoutStyledTable():
from autobasedoc.styledtable import StyledTable
styled = StyledTable(gridded=True)
styled.setTableData([
["Product", "Q1", "Q2"],
["Widget A", "100", "120"],
["Widget B", "80", "95"],
])
styled.addTableStyleCommand(("ALIGN", (0, 0), (-1, -1), "CENTER"))
table = styled.layoutStyledTable(colWidths=[4, 3, 3], rowHeights=[1.0, 0.8, 0.8])
content.append(table)
Examples and Documentation
- Example script:
tests/example.py - Larger document example:
tests/example_document.py - Sphinx docs source:
sphinx_doc/ - API docs: Read the generated Sphinx reference or inspect module docstrings
Testing
Install test dependencies and run the suite:
pip install -e ".[test]"
MPLBACKEND=Agg pytest -q
Coverage run:
MPLBACKEND=Agg pytest --cov=autobasedoc --cov-report=term-missing
Release Notes
Version 1.1.11 includes the current packaging cleanup, documentation fixes, and rowHeights forwarding support for styled table layout helpers.
License
This project is licensed under the BSD-3-Clause License. See LICENSE.md.
Links
- Homepage: https://github.com/NuCOS/autobasedoc
- Package: https://pypi.org/project/autobasedoc/
- Documentation: http://autobasedoc.readthedocs.io/
- Issues: https://github.com/NuCOS/autobasedoc/issues
Metadata
Release files for autobasedoc 1.1.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| autobasedoc-1.1.11.tar.gz | 3.4 MB | Without provenance | Details for autobasedoc-1.1.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| autobasedoc-1.1.11-py3-none-any.whl | Python 3 | none | any | Details for autobasedoc-1.1.11-py3-none-any.whl |
Total release size: 6.9 MB
Release files / autobasedoc-1.1.11.tar.gz
| Download URL | autobasedoc-1.1.11.tar.gz |
|---|---|
| Size | 3.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ae2242c17986b075c246954107d8f64b96b5c48645698623a8a54ce99d20d12
|
|
BLAKE2b-256 checksum How to use checksums |
411c8cad56ff4945f8c4653c0101a9eaacae18358ef4a9b406cef5210f138260
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / autobasedoc-1.1.11-py3-none-any.whl
| Download URL | autobasedoc-1.1.11-py3-none-any.whl |
|---|---|
| Size | 3.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8552a61469893d013384a57f2cd736f45e1bf84ff128b3af2c7b43823dec6e2c
|
|
BLAKE2b-256 checksum How to use checksums |
7f7227225bb73283fe99ac7e5c65be1e8e0ca62eb7975a11bd076cdcef679989
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for autobasedoc 1.1.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.