> ## 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.

# How do I generate a PDF with custom styles from an LLM?

> Send your LLM's Markdown to Doconda with format pdf and the look in one sentence: you get a laid-out PDF with the font embedded.

To generate a PDF with custom styles from an LLM, ask your model for its answer in Markdown and send it to Doconda
with `format: "pdf"` and the look in `style`. You get a laid-out PDF (headings, tables, page numbers) with the font
embedded, so it looks the same everywhere.

## Steps

1. Ask your model to answer in Markdown (headings with `#`, lists, tables).
2. Store your API key in `DOCONDA_API_KEY` and install the SDK (`pip install doconda` or `npm install @doconda/sdk`).
3. Send that Markdown with `format: "pdf"` and the style, and download the PDF.

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

  markdown = "# Quarterly summary\n\n| Month | Sales |\n|---|---|\n| January | €12,400 |"  # your LLM's answer

  doconda = Doconda()  # reads the key from DOCONDA_API_KEY
  doc = doconda.documents.create(
      format="pdf",
      content={"markdown": markdown},
      style="Inter 11 font, dark blue headings, 2 cm margins, number the pages",
  )
  Path("summary.pdf").write_bytes(doconda.documents.download(doc["id"], "pdf"))
  ```

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

  const markdown = "# Quarterly summary\n\n| Month | Sales |\n|---|---|\n| January | €12,400 |" // your LLM's answer

  const doconda = new Doconda()
  const doc = await doconda.documents.create({
    format: "pdf",
    content: { markdown },
    style: "Inter 11 font, dark blue headings, 2 cm margins, number the pages",
  })
  await writeFile("summary.pdf", await doconda.documents.download(doc.id, "pdf"))
  ```
</CodeGroup>

If you'd rather have Doconda write the content, swap `content` for `prompt` ("Quarterly summary for the board, with
blue headings"): the style asked for in the sentence is applied too.

## What you get back

* A PDF with the font embedded. With `format: "pdf"` you get only the PDF; with `docx` you also get the editable Word
  file.
* `style_applied`: how the style was understood, and `style_unsupported`: what couldn't be applied.
* `status`: `ready`, `ready_with_warnings`, `needs_review` or `failed` (not charged).
* A report with what's worth checking (`documents.report(id)`).

## Limits

* With `quality: "fast"` you get the basic style: font, size, colors, alignment, margins, cover page, table of
  contents, header and footer.
* The links in `outputs` expire after 5 minutes; `documents.outputs(id)` gives you new ones.
* Fonts: any Google Fonts family plus Calibri, Cambria, Arial, Times New Roman and Courier New. A font that doesn't
  exist comes back in `style_unsupported`.

## FAQ

<AccordionGroup>
  <Accordion title="Do I have to maintain templates or print CSS?">
    No. You describe the look in a sentence and the layout adapts to the kind of document (a contract, with numbered
    clauses; a letter, without page numbers).
  </Accordion>

  <Accordion title="Can I add images?">
    Yes. Upload them with `files.upload`, pass them in `sources` and place them in the Markdown with `![Caption](img:1)`.
  </Accordion>

  <Accordion title="What if I also need the Word file?">
    Use `format: "docx"`: you get the Word file and its PDF.
  </Accordion>
</AccordionGroup>

## Keep reading

* [Create](/en/guides/create) and [Style](/en/guides/style).
* [Quickstart](/en/quickstart).


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