
Introduction
If you work in a legal aid organization in the US or UK, you’ve seen the same pattern again and again: staff collect the same facts, copy/paste them into multiple forms, fix formatting issues at the end, and still worry something got missed.
That’s exactly what docassemble was built to solve.
Docassemble is an open-source platform for guided interviews and document assembly. You collect structured answers once, then generate consistent outputs—PDF, DOCX, and RTF—every time.
In this guide, you’ll learn practical, developer-friendly ways to generate PDF & DOCX documents using docassemble, including the most common template approaches, how attachments work, and the small implementation choices that prevent formatting headaches later—especially in high-volume legal aid workflows.
How docassemble generates documents (the 3 common approaches)
Docassemble supports multiple document assembly methods. The right one depends on whether you want a Word template, a fillable PDF, or a text-driven document.
1) DOCX template → output as DOCX or PDF
You prepare a Word template and insert variables into it. Docassemble can generate a DOCX output, and it can also convert the same template into a PDF output.
This is the most popular route for legal aid because:
- staff already have Word templates
- formatting stays familiar
- you can maintain “official” Word master files and still output PDFs for filing
2) Fillable PDF template (form fields)
If you have an existing fillable PDF (Acrobat form fields), you can place the template in your package and have docassemble fill the fields using interview variables.
This is great when:
- courts require a specific PDF form
- field names are standardized
- you need pixel-perfect alignment with an official form
3) Plain text / Markdown document blocks
You can also write attachments with text blocks and formatting markup. This is useful for letters, notices, and simple documents where you don’t need strict court form structure.
The building blocks: templates, variables, and attachments
In docassemble, the “magic” is typically the attachment block: it takes a template and merges it with your interview variables to produce a file the user can download.
Where templates live
- In a package: data/templates/
- In Playground: the “Templates” folder
What gets merged into templates
Your interview variables: names, addresses, dates, checkboxes, conditional sections, signatures, etc.
For legal aid, this is the key advantage: once your interview logic is solid, the documents become consistent and repeatable—less “tribal knowledge,” fewer last-minute edits.
Technical code section: generate DOCX + PDF from a DOCX template
Below is a simple interview skeleton that:
- asks a few questions
- generates a DOCX (and optionally a PDF) from a DOCX template
1) Example interview YAML (minimal)
metadata:
title: Simple Letter Generator
description: Generate a DOCX/PDF letter using docassemble
mandatory: True
code: |
client_name
client_address
final_screen
question: Client details
fields:
- Full name: client_name
- Address: client_address
event: final_screen
question: Your document is ready
subquestion: |
Download your letter below.
attachments:
- name: Letter
filename: letter
docx template file: letter_template.docx
valid formats:
- docx
- pdf
2) Example DOCX template snippet
In letter_template.docx, place variables like:
- {{ client_name }}
- {{ client_address }}
Docassemble will merge those values at runtime. (This is the classic docassemble Word-template approach described in the official documentation.)
Technical code section: generate a PDF using a fillable PDF template
If you have an official court form PDF with fields, docassemble can fill them:
question: Case details
fields:
- Case number: case_number
- Court name: court_name
question: Download your filled form
attachment:
name: Filled Court Form
filename: court_form
pdf template file: official_court_form.pdf
fields:
- "case_number_field_name": case_number
- "court_name_field_name": court_name
Output quality best practices (what legal aid teams care about)
1) Separate “inputs” from “outputs”
Treat the interview as the source of truth. Documents should be generated outputs, not hand-edited “final artifacts.” This makes updates safer (new form versions, new clauses, policy changes).
2) Build validations before the attachment step
It’s cheaper to catch errors before document generation:
- missing dates
- incomplete addresses
- required declarations not selected
Docassemble supports logic/branching in interviews (YAML + Python) to enforce this.
3) Keep templates versioned and named clearly
Legal forms change. Store:
- formname_v2026_02.docx
- “effective date” notes in metadata
- interview version tags (helps audits)
4) If you integrate with other systems, decide what “system of record” is
Many legal aid orgs use CRMs/case systems for case records and docassemble for the interview + document engine. Docassemble supports an HTTP API for integrations when you need it.
Need help building production-grade docassemble interviews (logic + validations + clean documents)?
We help legal aid teams implement docassemble workflows, templates, and integrations with stable output formatting and fewer support tickets.
Talk to a Docassemble DeveloperFAQs
1) Can docassemble generate both PDF and DOCX?
Yes. Docassemble supports generating documents in PDF, DOCX, and RTF, including DOCX templates that can output DOCX or be converted to PDF.
2) Should legal aid teams start with DOCX templates or PDF form templates?
If you want flexible formatting and easy edits, start with DOCX templates. If courts require a specific official PDF form layout, use a fillable PDF template.
3) Why does my PDF look different than my DOCX?
DOCX → PDF conversion can introduce formatting differences (fonts, spacing, tables). Testing in LibreOffice early helps catch issues before launch.
4) Where do I store templates in docassemble?
Templates go in the package data/templates folder (or the Playground “Templates” folder).
5) Can I generate a full packet of documents (not just one file)?
Yes—docassemble can generate multiple attachments in one flow. Many legal aid workflows produce a packet (cover letter + declarations + exhibits) once the interview is complete.
6) Can docassemble integrate with our case management system?
Yes. Docassemble offers an HTTP API for integrations, so external systems can trigger interviews or receive generated outputs depending on your architecture.