Complete reference for all public classes, functions, and components in DocForge.
Module: docforge.generator
The high-level API for creating documents. Wraps PDF and Word generation with theme support.
DocumentGenerator(theme: Theme | None = None)| Parameter | Type | Default | Description |
|---|---|---|---|
theme |
Theme | None |
DEFAULT_THEME |
Theme for all generated documents |
Create a professional PDF with a cover page.
| Parameter | Type | Description |
|---|---|---|
filepath |
str |
Output file path |
title |
str |
Document title (cover page and header) |
content |
dict | str |
Markdown string, or dict with "sections" or "generated_content" key |
metadata |
dict | None |
Keys: author, organization, document_type, location, client |
Returns the filepath written to.
Supported document_type values: business_plan, grant_application, marketing_plan, financial_projection, executive_summary, pitch_deck, report, proposal, whitepaper
Create a PDF without a separate cover page. Title, metadata table, and content appear on the first page.
Same parameters as create_pdf.
Create a one-page resume PDF with tight spacing.
| Parameter | Type | Description |
|---|---|---|
filepath |
str |
Output file path |
name |
str |
Full name (large, centered) |
subtitle |
str |
Role tagline (e.g., "QA ENGINEER | AUTOMATION") |
contact |
str |
Contact info line |
content |
str |
Markdown body (## sections, ### job titles, bullets) |
Create a formatted Word document. Requires pip install docforge[word].
Same parameters as create_pdf.
Module: docforge.theme
Dataclass that defines all visual properties for document generation.
See Theming Guide for full property reference and examples.
from docforge import Theme
theme = Theme(
name="my-brand",
brand_name="My Company",
primary="#3B82F6",
footer_text="My Company — Confidential",
)Module: docforge.invoice
@dataclass
class InvoiceLineItem:
description: str
amount: float
quantity: int = 1
included: bool = False@dataclass
class InvoiceData:
invoice_number: str
issue_date: str
due_date: str = "Upon Receipt"
project: str = ""
client_name: str = ""
business_name: str = ""
client_location: str = ""
items: list[InvoiceLineItem] = field(default_factory=list)
notes: list[str] = field(default_factory=list)
payment_methods: list[str] = field(default_factory=...)
remittance_notes: list[str] = field(default_factory=list)Computed properties:
subtotal— Sum of non-included items (amount * quantity)total— Currently equals subtotal
generate_invoice(filepath: str, data: InvoiceData, theme: Theme | None = None) -> strGenerate a branded invoice PDF. Returns the filepath written to.
If no theme is provided, uses a default HLN-branded theme.
Module: docforge.pdf.components
Low-level flowable components for building custom document layouts.
accent_divider(
theme: Theme | None = None,
use_secondary: bool = False,
thickness: int = 2,
space_before: int = 6,
space_after: int = 12,
) -> HRFlowableThemed horizontal divider line. Set use_secondary=True to use the secondary color.
cover_page(
story, styles, title, doc_type, date_str, author, organization,
location="", tagline="", theme=None, client="",
) -> NoneBuild a professional cover page and append it to the story. Includes a page break and template switch to "Standard" for subsequent pages.
section_header(story, styles, title, new_page=True, theme=None) -> None
subsection_header(story, styles, title) -> Noneadd_paragraph(story, styles, text) -> None
add_bullet_list(story, styles, items: list[str]) -> None
add_numbered_list(story, styles, items: list[str]) -> None
add_callout(story, styles, text) -> Noneadd_table(
story, data: list[list], col_widths=None,
style="standard", theme=None,
) -> Nonestyle value |
Description |
|---|---|
"standard" |
Themed header + alternating row backgrounds |
"simple" |
Themed header only |
add_metadata_table(story, metadata_pairs: list[list[str]], theme=None) -> NoneKey-value pair table with gray label column.
parse_markdown_content(content: str, story, styles, theme=None) -> None
parse_resume_content(content: str, story, styles, theme=None) -> None
convert_markdown_inline(text: str) -> strModule: docforge.pdf.document
Full document with cover page and standard page templates. Uses draw_cover_footer on the first page and draw_footer on subsequent pages.
Simpler document with a single page template. All pages use draw_footer.
Both accept filepath and an optional theme parameter.
Module: docforge.export
from docforge.export import ChatExportService, ChatMessage, ExportMetadata
messages = [
ChatMessage(role="user", content="Hello"),
ChatMessage(role="assistant", content="Hi there!"),
]
metadata = ExportMetadata(title="Support Chat", brand_name="Acme Corp")
ChatExportService.export(messages, metadata, fmt="pdf", export_dir="./exports")Supported formats: txt, pdf, csv, xlsx
Module: docforge.theme
build_styles(theme: Theme | None = None) -> dict[str, ParagraphStyle]
build_resume_styles(theme: Theme | None = None) -> dict[str, ParagraphStyle]
table_style(theme: Theme | None = None) -> list
simple_table_style(theme: Theme | None = None) -> listModule: docforge.theme
draw_footer(canvas, doc, theme=None) # Standard pages with page numbers
draw_cover_footer(canvas, doc, theme=None) # Cover page with centered branding