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

# Extract text

> Extract raw text content from a PDF without OCR.

## Phase

**Phase 2** — Text extraction (non-OCR). Uses embedded text layers.

## Request

<ParamField body="source" type="object" required>
  The PDF to extract from. One of:

  * `{ "pdf_id": "pdf_abc123" }`
  * `{ "url": "https://example.com/doc.pdf" }`
  * `{ "base64": "JVBERi0x..." }`
</ParamField>

<ParamField body="pages" type="string" default="all">
  Which pages to extract. `"all"`, `"1-3"`, `"1,3,5"`.
</ParamField>

<ParamField body="format" type="string" default="text">
  Output format:

  * `text` — Plain text, pages separated by `\n\n---\n\n`.
  * `markdown` — Best-effort markdown conversion (headings, lists, tables).
  * `structured` — JSON with per-page text, bounding boxes, and reading order.
</ParamField>

## Response

### text format

```json theme={null}
{
  "id": "ext_abc123",
  "object": "extraction",
  "status": "completed",
  "format": "text",
  "pages_extracted": 5,
  "content": "Page 1 content here...\n\n---\n\nPage 2 content here...",
  "word_count": 2450,
  "created_at": "2026-05-19T13:00:00Z"
}
```

### structured format

```json theme={null}
{
  "id": "ext_abc123",
  "object": "extraction",
  "status": "completed",
  "format": "structured",
  "pages": [
    {
      "page": 1,
      "text": "Full page text...",
      "blocks": [
        {
          "text": "Invoice #001",
          "type": "heading",
          "bbox": { "x": 50, "y": 50, "width": 200, "height": 30 }
        }
      ]
    }
  ]
}
```

<Note>
  This endpoint extracts text from the PDF's text layer. For scanned documents or images, use the [OCR endpoint](/docs/api-reference/extract/ocr).
</Note>

## Example

```bash theme={null}
curl -X POST https://api.pdfbase.dev/v1/extract/text \
  -H "Authorization: Bearer pk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "source": { "pdf_id": "pdf_report" },
    "pages": "1-5",
    "format": "markdown"
  }'
```
