# PDF, Word, Excel and PowerPoint to Markdown

> format markdown or text also converts documents: PDF, Word, Excel, PowerPoint, OpenDocument and CSV become Markdown or text, with pages counted and a page limit.

Source: https://docs.virginproxy.com/documents/

When the address is a document, `format: "markdown"` or `"text"` converts it like a web page: headings, paragraphs, lists and tables come out as Markdown – ready for search, an index or a language model.

**cURL**

```bash
curl https://api.virginproxy.com/v1/requests \
  -H "Authorization: Bearer $VP_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/annual-report-2025.pdf",
    "format": "markdown",
    "format_options": {
      "max_pages": 20
    }
  }'
```

**Python**

```python
import os, requests

r = requests.post(
    "https://api.virginproxy.com/v1/requests",
    headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
    json={
        "url": "https://example.com/annual-report-2025.pdf",
        "format": "markdown",
        "format_options": {"max_pages": 20},
    },
    timeout=180,
)
data = r.json()
if not r.ok:
    raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["document"], data["tokens"])
print(data["body"])
```

**Node.js**

```javascript
const res = await fetch("https://api.virginproxy.com/v1/requests", {
  method: "POST",
  headers: { Authorization: "Bearer " + process.env.VP_KEY, "Content-Type": "application/json" },
  body: JSON.stringify({
    url: "https://example.com/annual-report-2025.pdf",
    format: "markdown",
    format_options: { max_pages: 20 },
  }),
  signal: AbortSignal.timeout(180_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.document, data.tokens);
console.log(data.body);
```

**Python SDK**

```pysdk
from virginproxy import VirginProxy  # docs.virginproxy.com/sdk/virginproxy.py

vp = VirginProxy()  # reads VP_KEY
data = vp.request({
    "url": "https://example.com/annual-report-2025.pdf",
    "format": "markdown",
    "format_options": {"max_pages": 20},
})
print(data)
```

**Node SDK**

```nodesdk
import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs

const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.request({
  url: "https://example.com/annual-report-2025.pdf",
  format: "markdown",
  format_options: { max_pages: 20 },
});
console.log(data);
```

**PHP**

```php
<?php
$ch = curl_init("https://api.virginproxy.com/v1/requests");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 180,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("VP_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "url" => "https://example.com/annual-report-2025.pdf",
        "format" => "markdown",
        "format_options" => ["max_pages" => 20],
    ], JSON_UNESCAPED_SLASHES),
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
    exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo json_encode([$data["document"], $data["tokens"]], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), PHP_EOL;
echo $data["body"], PHP_EOL;
```

**Go**

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
	"time"
)

func main() {
	payload := []byte(`{
  "url": "https://example.com/annual-report-2025.pdf",
  "format": "markdown",
  "format_options": {
    "max_pages": 20
  }
}`)
	req, err := http.NewRequest("POST", "https://api.virginproxy.com/v1/requests", bytes.NewReader(payload))
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 180 * time.Second}
	res, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()

	var data map[string]any
	if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
		log.Fatal(err)
	}
	if res.StatusCode >= 300 {
		e := data["error"].(map[string]any)
		log.Fatalf("%v: %v", e["code"], e["message"])
	}
	fmt.Println(data["document"], data["tokens"])
	fmt.Println(data["body"])
}
```

POST`/v1/requests`[≈ 1 credit](https://docs.virginproxy.com/billing/#cost)[Open in Playground](https://dash.virginproxy.com/playground#request=eyJ1cmwiOiJodHRwczovL2V4YW1wbGUuY29tL2FubnVhbC1yZXBvcnQtMjAyNS5wZGYiLCJmb3JtYXQiOiJtYXJrZG93biIsImZvcm1hdF9vcHRpb25zIjp7Im1heF9wYWdlcyI6MjB9fQ)

*Response (shortened):*

```json
{
  "status": 200,
  "format": "markdown",
  "body": "# Annual Report 2025\n\n## Letter to shareholders\n\nThe year …",
  "body_encoding": "utf8",
  "document": { "type": "pdf", "pages": 20, "truncated": true, "text": true },
  "tokens": 18420,
  "cost": { "credits": 4 }
}
```

## What is converted

| Type | What you get |
| --- | --- |
| PDF | The text layer, page by page. A scanned PDF without text gives an empty body and `"text": false`. |
| Word (.docx), OpenDocument (.odt) | Headings, paragraphs, lists and tables. |
| Excel (.xlsx), CSV | Each sheet as a Markdown table (with `text`: tab-separated). |
| PowerPoint (.pptx) | Each slide with its title and text. |

The type is read from the answer's `Content-Type`, or from the file itself when the server sends a generic one. `format_options.max_pages` (1 to 500, default 100) limits pages, slides or sheets; `document.truncated` says when it cut. Without `format` the file comes back unchanged (base64).

## What it costs

Like any request: 1 credit per started MB of the file. The conversion is free.

> **Tip:** Combine with `redact` to black out e-mail addresses and phone numbers before the text goes into your index.
