> ## 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 summarize a PDF into a Word document via API?

> Upload the PDF and pass it in sources with a prompt like "Summarize this in 2 pages" and format docx: you get the summary in Word plus its PDF.

To summarize a PDF into a Word document, upload the PDF and pass it in `sources` with `format: "docx"` and what you
want in `prompt` ("Summarize the main measures for a client"). Doconda reads your files before writing and flags any
figures or citations that don't come from them.

## Steps

1. Store your API key in `DOCONDA_API_KEY` and install the SDK (`pip install doconda` or `npm install @doconda/sdk`).
2. Upload the PDF (and any images you want inside) with `files.upload`.
3. Create the document with `sources` and download the Word file.

<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
  law = doconda.files.upload("housing-law.pdf")
  photo = doconda.files.upload("facade.jpg")
  doc = doconda.documents.create(
      format="docx",
      prompt="Summarize the main measures for a client",
      sources=[law["id"], photo["id"]],
  )
  Path("summary.docx").write_bytes(doconda.documents.download(doc["id"], "docx"))
  ```

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

  const doconda = new Doconda()
  const law = await doconda.files.upload(await readFile("housing-law.pdf"), "housing-law.pdf")
  const photo = await doconda.files.upload(await readFile("facade.jpg"), "facade.jpg")
  const doc = await doconda.documents.create({
    format: "docx",
    prompt: "Summarize the main measures for a client",
    sources: [law.id, photo.id],
  })
  await writeFile("summary.docx", await doconda.documents.download(doc.id, "docx"))
  ```
</CodeGroup>

## What you get back

* An editable Word file with the summary, and its PDF. Images go inside, where they fit.
* Warnings in the report (`documents.report(id)`):
  * `content.unsupported_fact`: a figure, date or fact that isn't in your request or your sources.
  * `content.unsupported_citation` · `content.citation_to_review`: a legal citation that doesn't come from your sources.
  * `source.selected`: your sources were very long and the part about what you asked for was used.
  * `source.instructions`: a source tried to give orders; it was ignored.
* `status`: `ready`, `ready_with_warnings`, `needs_review` or `failed` (not charged).

## Limits

* In `sources`: up to 5 documents (Word, PowerPoint, Excel, PDF, also `.doc`, `.ppt` and `.xls`, TXT or Markdown) and
  up to 10 images, together.
* Each file up to 20 MB.
* For only the summary's PDF, use `format: "pdf"`; for a presentation, `format: "pptx"`.

## FAQ

<AccordionGroup>
  <Accordion title="Can I pass the PDF by URL without uploading it?">
    Yes. `sources` also accepts `{ "url": "https://…" }` or its bytes in base64 (`{ "data", "filename" }`). See
    [ways to pass a file](/en/guides/extract#four-ways-to-pass-a-file).
  </Accordion>

  <Accordion title="What if I only want the text for my own model?">
    Use [`extract`](/en/guides/extract): it returns the PDF as Markdown.
  </Accordion>

  <Accordion title="Can I use a document Doconda already made as a source?">
    Yes, by its id (`doc_…`).
  </Accordion>
</AccordionGroup>

## Keep reading

* [Create](/en/guides/create) and [SDK: create documents](/en/sdk/create).
* [Quickstart](/en/quickstart).


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