BINARY PDF · FLATEDECODE & ACROFORM

Pure-Stream Binary PDF Parser API: FlateDecode Text, Tables & /AcroForm to JSON Schema

Target Query: pdf invoice form extraction to json schema api · Category: Extraction Modality · Verified Rate: $0.015/hit ($0 on miss) · Updated: 2026-12-02

Direct Answer: Most web scraping APIs either choke on binary `application/pdf` links or route every PDF through expensive vision-LLM OCR pipelines at $0.10–$0.50 per document. Scrape-Anything includes a pure-stdlib binary PDF stream parser (`pdf_parser.py`) that decompresses `FlateDecode` (`zlib`) streams, decodes `BT..ET` text operators (`Tj`, `TJ`, `Tm`, `Td`, `T*`) and `ToUnicode` CMaps, extracts `/AcroForm` fields, reconstructs key-value pairs and multi-column rows into strict JSON Schema at `$0.025`/verified hit—and automatically rejects encrypted PDFs at `$0`.

Engineering Mechanics & Deterministic Guardrails

PDF Extraction Capabilities & Unit Economics

PDF FeatureParser ImplementationOutput FieldBilling Rule
Compressed `FlateDecode` StreamsPure `zlib` stream inflater + `BT..ET` operator engine`data.pages[]`, `data.text`, `markdown`$0.025 (25,000 micros) verified
`ToUnicode` CMap Tables`beginbfchar` / `beginbfrange` hex-to-UTF-16 decoderClean Unicode text extractionIncluded in $0.025 rate
`/AcroForm` Interactive FieldsPDF field dict parser (`/T`, `/V`, `/FT`)`data.form_fields{}`Included in $0.025 rate
Invoice Key-Value & TablesCoordinate clustering on Y/X baselines`data.key_values{}`, `data.tables[]`Schema-validated before charge
Password / Encrypted PDF (`/Encrypt`)Early header/trailer `/Encrypt` detector`ok: false`, `blocked_reason: encrypted_pdf`$0.00 (`0` micros) guaranteed
Pure-Stream Multi-Format Latency vs Headless Browser Stacks (Relative Overhead) Headless Chrome Pool + Residential Proxy 3,200-8,500 ms LLM Markdown-to-JSON Two-Pass Pipeline 1,800-4,500 ms Scrape-Anything PDF FlateDecode Stream 15-120 ms Scrape-Anything Complex HTML Table Grid 10-90 ms Scrape-Anything __NEXT_DATA__ / JSON-LD 8-60 ms Scrape-Anything Binary .xlsx / CSV Gate 5-50 ms SQLite WAL Verified Archive Cache Hit < 5 ms

PDF Invoice Extraction JSON Schema

{
  "type": "object",
  "required": [
    "key_values",
    "tables"
  ],
  "properties": {
    "key_values": {
      "type": "object",
      "required": [
        "Invoice Number",
        "Total"
      ],
      "properties": {
        "Invoice Number": {
          "type": "string",
          "minLength": 3
        },
        "Total": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "tables": {
      "type": "array",
      "minItems": 1
    }
  }
}

Any extracted payload violating required keys, types, bounds, or regex patterns returns schema_valid: false, exact validation_errors, and billed_micros: 0.

Executable REST, Remote /mcp & treg hub Snippets

curl -fsSL -X POST "https://scrape.fastmesh.dev/v1/extract" \
  -H "Content-Type: application/json" \
  -d '{
    "content_base64": "<BASE64_ENCODED_PDF>",
    "content_type": "application/pdf",
    "format_hint": "pdf",
    "json_schema": {
      "type": "object",
      "required": ["text"],
      "properties": { "text": { "type": "string", "minLength": 10 } }
    }
  }'

curl -fsSL -X POST "https://scrape.fastmesh.dev/mcp" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":5,"method":"tools/call","params":{"name":"scrape_pdf","arguments":{"url":"https://example.org/invoice-sample.pdf"}}}'

Hard guarantee: fake-200 CAPTCHA/Turnstile shells, login walls, encrypted PDFs, empty results, schema mismatches, and SSRF HTTP 422 blocks always return billed_micros: 0.

Test Schema-Validated Extraction Live in 5 Seconds

Paste any public URL, HTML table, JSON-LD, CSV, or fake-200 shell at scrape.fastmesh.dev or top up once with never-expiring Creem prepaid credits ($15 Starter / $59 Growth / $199 Scale — $0/mo recurring).

Frequently Asked Questions

Can I pass a public PDF URL or upload base64 PDF bytes?

Both are supported. Pass `url` for a public HTTPS PDF or `content_base64` with `content_type: "application/pdf"` for private inline parsing.

What happens when an uploaded or linked PDF is encrypted or scanned-only with zero extractable text?

Encrypted PDFs return `blocked_reason: "encrypted_pdf"` and `billed_micros: 0`. Scanned image-only PDFs with empty text fail schema/empty checks and also return `billed_micros: 0`.

How much does verified PDF extraction cost on prepaid packs?

Base rate is 25,000 micros (`$0.025`), so the $15 Starter pack covers 600 verified PDFs, $59 Growth covers 3,000 PDFs, and $199 Scale covers 12,000 PDFs—with same-tenant cache refreshes at `$0.0025`.

Related Structured Extraction Guides

Explore all 32 Scrape-Anything Technical Guides or inspect the machine-readable llms.txt index.