# PDF Table Extractor

PDF, scanned-PDF or image links in; every table found comes back as rows (JSON), CSV and markdown. Text PDFs are read from the text layer (exact numbers); scanned pages and photos go through Tesseract OCR with table detection. No LLM, deterministic output.

- **Endpoint:** `POST https://api.apify.com/v2/acts/rentley~pdf-tables/run-sync-get-dataset-items`
- **Auth:** `Authorization: Bearer <Apify API token>`
- **Price:** $0.002 per text-PDF page with a table, $0.005 per scanned page or image with a table. Pages with no table, failed downloads and unreadable files are free. + $0.00005 per GB of run memory per run.
- **Good for:** turning report, budget, statement and invoice tables into spreadsheets; feeding table data to an LLM as markdown; bulk PDF-to-CSV.
- **Store page:** https://apify.com/rentley/pdf-tables

## Call it

```bash
curl -s -X POST "https://api.apify.com/v2/acts/rentley~pdf-tables/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" -H "Content-Type: application/json" \
  -d '{"urls": ["https://raw.githubusercontent.com/camelot-dev/camelot/master/docs/_static/pdf/foo.pdf"]}'
```

## Input

| Field | Type | Default | What it does |
|---|---|---|---|
| `urls` | array of string | required | Public links to PDFs (text or scanned) or images (PNG, JPG). Up to 60 MB each. |
| `pages` | string | all | Pages to read, e.g. "1-3,7". |
| `ocr` | string (auto / always / never) | "auto" | Auto runs OCR only on pages without a text layer. |
| `languages` | array (eng, deu, fra, spa, por, ita, nld) | ["eng"] | OCR languages. |
| `maxPagesPerFile` | integer | 50 | Stop reading a file after this many pages. |

## Output (one item per table)

`url`, `page`, `tableIndex`, `method` (text-layer/lines, text-layer/text or ocr), `rowCount`, `columnCount`, `header`, `rows` (array of arrays of strings), `csv`, `markdown`. Failed links come back as `{url, error}` and are not charged. Key-value record `SUMMARY` counts files, pages, tables and failures.

## Limits

- Best on tables with ruling lines or clear column gaps. Dense sub-columns without lines can come back stacked in one cell.
- OCR accuracy depends on scan quality; check OCR numbers before relying on them.
- Public links only; password-protected PDFs are skipped.
