> ## Documentation Index
> Fetch the complete documentation index at: https://docs.doconda.com/llms.txt
> Use this file to discover all available pages before exploring further.

# A python-docx alternative without templates

> How to generate a Word (.docx) file from Python without templates or layout code, with editable headings, tables and styles.

To generate a Word file from Python without templates, send your content as Markdown (or a sentence) to Doconda and
get back the laid-out `.docx`, plus its PDF. You don't write code for paragraphs, styles or tables: you describe the
look in one sentence (`style`) and it is applied to Word's styles, so the file stays editable.

## The problem in practice

* Every heading, list and table is code: adding a new section means changing the program.
* `.docx` templates have to be designed, versioned and kept in sync with their placeholders.
* When formatting is applied paragraph by paragraph, the document looks right but is hard to edit later in Word.
* Tables that overflow the page or headings stranded at the bottom of a page only show up when you open the file.

## The solution with Doconda

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
  from pathlib import Path
  from doconda import Doconda

  doconda = Doconda()  # reads the key from DOCONDA_API_KEY
  doc = doconda.documents.create(
      format="docx",
      content={"markdown": "# Internal note\n\nMonday's meeting moves to 10:00."},
      style="Lora font, blue headings, with page numbers",
  )
  Path("note.docx").write_bytes(doconda.documents.download(doc["id"], "docx"))
  ```

  ```ts TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
  import { writeFile } from "node:fs/promises"
  import { Doconda } from "@doconda/sdk"

  const doconda = new Doconda()
  const doc = await doconda.documents.create({
    format: "docx",
    content: { markdown: "# Internal note\n\nMonday's meeting moves to 10:00." },
    style: "Lora font, blue headings, with page numbers",
  })
  await writeFile("note.docx", await doconda.documents.download(doc.id, "docx"))
  ```
</CodeGroup>

With no content of your own, ask for the document in a sentence: `prompt="Residential lease agreement for €900 a month"`.

## What you get back

* The `.docx` and its PDF (`doconda.documents.download(doc["id"], "pdf")`).
* `status`: `ready`, `ready_with_warnings`, `needs_review` or `failed` (not charged).
* `style_unsupported`: what you asked for in `style` that could not be applied. Never silently ignored.
* A report (`documents.report(id)`) with anything worth checking.

## FAQ

<AccordionGroup>
  <Accordion title="How do I create a Word document in Python without a template?">
    Install the SDK (`pip install doconda`) and call `documents.create` with `format="docx"` and your Markdown in
    `content`. The look goes in `style`, in plain language. No template file is needed.
  </Accordion>

  <Accordion title="Can the generated Word file be edited afterwards?">
    Yes. Style is applied to Word's styles (Normal, Heading 1…), not paragraph by paragraph. Change a style in Word
    and the whole document follows.
  </Accordion>

  <Accordion title="Can I convert Markdown to docx with tables and lists?">
    Yes. The Markdown supports headings, paragraphs, lists, tables, bold and italics, links, page breaks and images.
    The text is used as is.
  </Accordion>
</AccordionGroup>

## Keep reading

* [Create](/en/guides/create): every creation option.
* [Review](/en/guides/review): fix a Word file you already have.
* [Python SDK](/en/sdk/python) and [TypeScript SDK](/en/sdk/introduction).
* [Examples on GitHub](https://github.com/B-C-Software/doconda-examples).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.