Install & Compatibility
Where this runs
tested against v4.5.1.20260827 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.5MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 2.3s · import 0.000s · 19MB
65MB installed
● package 65MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Canvas
✓ from reportlab_stubs.pdfgen.canvas import Canvas
✗ from reportlab.pdfgen.canvas import Canvas
This quickstart demonstrates how to create a basic PDF document using ReportLab's PLATYPUS API, with explicit type hints that `types-reportlab` would validate. Remember that `reportlab` itself must be installed for this code to run.
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.pagesizes import letter
from typing import List
def generate_simple_pdf(filename: str, title_text: str, paragraph_content: str) -> None:
"""Generates a simple PDF document using ReportLab with type hints."""
doc: SimpleDocTemplate = SimpleDocTemplate(filename, pagesize=letter)
story: List[Any] = [] # Use Any for flowables for simplicity here
styles = getSampleStyleSheet()
# Add a title
title_style = styles['h1']
title: Paragraph = Paragraph(title_text, title_style)
story.append(title)
story.append(Spacer(1, 0.2 * inch)) # type: ignore
# Add a paragraph
body_style = styles['Normal']
paragraph: Paragraph = Paragraph(paragraph_content, body_style)
story.append(paragraph)
doc.build(story)
print(f"PDF '{filename}' generated successfully.")
if __name__ == "__main__":
from reportlab.lib.units import inch # type: ignore
generate_simple_pdf(
"hello_typed_report.pdf",
"My Typed ReportLab Document",
"This is a sample paragraph for a PDF generated using ReportLab, "
"with type checking enhanced by types-reportlab stubs."
)
Debug
Known issues
gotchaInstalling `types-reportlab` alone does NOT provide runtime functionality. It only provides type annotations. You must install the actual `reportlab` library (and its dependencies like `Pillow` for images) separately for your code to execute.fixEnsure `pip install reportlab` (and optionally `pip install Pillow`) is run in your environment alongside `pip install types-reportlab`.
affects: All versions
gotchaType checking failures may occur if the version of `types-reportlab` does not align with your installed `reportlab` version. `types-reportlab` versions are specifically tailored to a corresponding `reportlab` version (e.g., `4.4.10.20260408` targets `reportlab==4.4.10`).fixMatch the `types-reportlab` stub version as closely as possible to your `reportlab` runtime version. Consider using version specifiers in your `requirements.txt` (e.g., `types-reportlab~=4.4.10`).
affects: All versions
breakingWhile stub packages themselves don't typically 'break' runtime code, updates to `typeshed` stubs can introduce stricter type checking rules or corrections that might cause existing code to fail type checking, even if the runtime behavior of `reportlab` hasn't changed.fixAddress new type checker errors by adjusting your code to conform to the corrected type hints, or temporarily pin the `types-reportlab` version if immediate changes are not feasible.
affects: All versions (with typeshed updates)
gotchaReportLab's documentation can sometimes be challenging to navigate, with some examples considered outdated or incomplete by community members, leading to difficulties in finding specific patterns or features.fixConsult community resources, blog posts, and thoroughly explore the ReportLab API reference and source code for deeper understanding beyond the official user guide. Experimentation with `dir()` and an interactive debugger (`ipdb`) can also be helpful.
affects: All versions
Upgrade
Version history
4.5.1.20260827latest on PyPI · released Aug 27, 2026
Audit
Dependencies
reportlabrequiredProvides the runtime functionality for which these stubs offer type hints. types-reportlab targets reportlab==4.4.10.
PillowoptionalReportLab uses Pillow for image handling.
pythonrequiredRequired Python version.