> ## 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 extract text from a scanned PDF for an LLM?

> Call extract with the PDF: it returns Markdown with headings, tables and page markers, and reads scanned pages with OCR.

To extract the text of a PDF (scanned or not) for an LLM, call `extract` with the file. Doconda returns Markdown with
headings, tables and columns in order plus page markers, and reads scanned pages and their tables with OCR.

## Steps

1. Store your API key in `DOCONDA_API_KEY` and install the SDK (`pip install doconda` or `npm install @doconda/sdk`).
2. Call `extract` with a path, a public URL, bytes or a `file_…`/`doc_…` id.
3. Pass the `markdown` to your model.

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

  doconda = Doconda()  # reads the key from DOCONDA_API_KEY
  text = doconda.extract("proposal.pdf")["markdown"]
  print(text[:500])
  ```

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

  const doconda = new Doconda()
  const { markdown } = await doconda.extract("proposal.pdf")
  console.log(markdown.slice(0, 500))
  ```

  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
  curl https://api.eu.doconda.com/v1/extract \
    -H "Authorization: Bearer $DOCONDA_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{ "file": { "url": "https://example.com/contract.pdf" } }'
  ```
</CodeGroup>

## What you get back

```json theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
{
  "object": "extraction",
  "id": "doc_01JAB3…",
  "format": "pdf",
  "markdown": "<!-- page 1 -->\n\nLEASE AGREEMENT…",
  "chars": 18342,
  "truncated": false,
  "pages": 7
}
```

* `markdown`: the text with its structure. In a PDF, headings, tables and columns in order, with page markers.
* `chars`, `pages` and `truncated` (if it goes over 2,000,000 characters).

## Limits

* Up to 100 scanned pages per PDF; the rest come out marked as "not read". A PDF can have up to 1,000 pages.
* A long scanned PDF can take a few minutes: after 120 s the API answers `202` with `{ "id", "status" }` and you
  collect it with `GET /extract/{id}`. The SDK waits for you.
* Files up to 20 MB. URLs can only point to public addresses.

## FAQ

<AccordionGroup>
  <Accordion title="Which other formats does it read?">
    Word, PowerPoint, Excel (also `.doc`, `.ppt` and `.xls`), images (PNG, JPG, GIF, WebP), TXT and Markdown. In
    PowerPoint, one section per slide with its notes; in Excel, one table per sheet.
  </Accordion>

  <Accordion title="Does Doconda keep the PDF?">
    No. It's a read, not a document: nothing is kept once you have the text, and if you don't collect it, it's deleted
    after 15 minutes. A file sent by URL, base64 or `multipart` is also deleted after 15 minutes.
  </Accordion>

  <Accordion title="How much does it cost?">
    See the [pricing](/en/guides/account#pricing) table. It counts toward the 120 documents per minute limit.
  </Accordion>

  <Accordion title="What if I want the PDF to be searchable?">
    Review it with `operation: "review"`: it adds an invisible text layer (OCR) to scanned pages. See
    [Review](/en/guides/review).
  </Accordion>
</AccordionGroup>

## Keep reading

* [Read files](/en/guides/extract).
* [Quickstart](/en/quickstart).


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