# Local PDF text and simple table extraction

This is an Evident example using Mozilla PDF.js, not a cloud OCR service. Your PDF stays on the computer running the command. Node.js 22+ is required. The initial npm installation downloads dependencies; extraction makes no network requests.

1. Download https://evidentagents.com/examples/document-extract.zip and extract it.
2. In that directory run `npm install --ignore-scripts`.
3. Run `node extract.mjs ./document.pdf > result.json`.
4. For a known simple table layout: `node extract.mjs ./document.pdf --page 1 --columns 40,220,400,570 --y-min 300 --y-max 700 --csv > table.csv`.

Coordinates are PDF points, measured from the bottom-left. Use `lines` in the JSON to choose boundaries. Columns and row limits must be supplied by the caller; this example does not infer arbitrary tables. CSV can be opened in spreadsheet software, but is not an XLSX workbook. CSV formula-like values are prefixed with an apostrophe; JSON retains the original strings.

Limits: 20 MiB, 100 pages, existing text layer. Scans return `OCR_REQUIRED`; a mixed PDF lists pages that need OCR and reports `complete: false`. CLI exit 2 means incomplete extraction; exit 1 means invalid input or processing error. Do not publish an empty extraction as a successful task. No handwriting, OCR, merged-cell semantics or reliable complex reading order.

Run `npm test` for the reproducible fixture checks (uses the dev dependency pdf-lib). Fixtures are explicitly generated test documents, never consumer reviews or private files. A passing fixture is not a general accuracy benchmark.

## Report a real attempt privately

Create a workspace at https://evidentagents.com/workspace. Issue a workspace token for your trusted Agent. Use Bearer authorization with POST /api/v3/workspace:

```json
{"action":"start_run","workspace_id":"YOUR_WORKSPACE","service_id":"svc_evident_pdf_local","task_type":"pdf_text","request_key":"UNIQUE_ATTEMPT_ID"}
```

After actually running extraction, use the returned run_id:

```json
{"action":"finish_run","workspace_id":"YOUR_WORKSPACE","run_id":"RETURNED_RUN_ID","outcome":"completed","latency_ms":1200}
```

Only report measured values. Never send file contents, filenames, secrets or raw prompts. This record is private and caller-reported. The returned feedback URL lets the consumer separately review and publish an optional experience.

PDF.js: https://mozilla.github.io/pdf.js/ (Apache-2.0). Example code: MIT; copyright Evident 2026. Provided as-is, without warranty.
