pdfplumber Alternative for Scanned PDFs, Borderless Tables & Custom JSON
Keep pdfplumber for simple text PDFs—and route scanned, skewed, or multi-page tabular PDFs to a single zero-retention vision API.
Why pdfplumber Fails on Scanned PDFs & Complex Multi-Page Layouts
pdfplumber (built on pdfminer.six) gives Python developers fine-grained access to embedded characters and line coordinates. That works well until a customer uploads a scanned PDF—where page.extract_text() and page.extract_tables() return empty strings and empty lists because there is no digital text layer. Even on digital PDFs, borderless statements, rotated text, merged summary rows, and multi-page continuation tables require brittle per-vendor table_settings dictionaries and custom Tesseract fallback glue.
Hybrid Fallback or Full Replacement with POST /v1/pdf-extract
Call POST /v1/pdf-extract whenever pdfplumber finds no text layer—or route every incoming PDF through one unified pipeline. In a single call you can extract stitched multi-page tables (mode=tables), combine tables + key-value metadata (mode=auto), or enforce a custom schema (mode=json) so downstream services receive predictable JSON. Test your document interactively in our free PDF to JSON converter or PDF table extractor.
Common pdfplumber Upgrade Patterns
- Automatic Fallback for Image-Only Scanned PDFs: Detect zero-text PDFs in your Python ingestion worker and send them to POST /v1/pdf-extract instead of chaining pdf2image + Tesseract + custom column heuristics.
- Custom JSON Schema + Tables in One Call: Pass a field list or strict JSON Schema alongside mode=auto to pull account numbers, statement dates, and stitched transaction tables together.
- Multi-Page Statements Without Header Deduplication Hacks: Let stitch_tables=true merge matching continuation tables across up to 20 pages and strip repeated headers automatically.
- Zero Local OCR Infrastructure: Skip managing Poppler, Tesseract language packs, and high-RAM image rendering pods in production.
Python Implementation: Scanned PDF to Stitched Tables + Custom JSON
Send the raw PDF via multipart/form-data to POST https://api.structocr.com/v1/pdf-extract. Pass mode=auto with a simple JSON field array (or full JSON Schema) to retrieve both custom_data and stitched document.tables[]. Full schema rules are documented in the PDF Extract API docs.
Prerequisite: Python 3.9+ (`pip install requests`; optional `pdfplumber` only if keeping a local text check)
import json
import os
import requests
schema_fields = [
"statement_period",
"account_holder",
"currency",
"opening_balance",
"closing_balance",
]
with open("scanned_statement.pdf", "rb") as pdf_file:
response = requests.post(
"https://api.structocr.com/v1/pdf-extract",
headers={"x-api-key": os.environ["STRUCTOCR_API_KEY"]},
files={"file": ("scanned_statement.pdf", pdf_file, "application/pdf")},
data={
"mode": "auto",
"pages": "all",
"stitch_tables": "true",
"schema": json.dumps(schema_fields),
},
timeout=90,
)
response.raise_for_status()
result = response.json()
print("Custom fields:", result["custom_data"])
for table in result["document"]["tables"]:
print(table["id"], table["page_range"], f"rows={len(table['rows'])}", f"stitched={table['stitched']}")Technical Specs
- •Image-Only Scanned PDFs: pdfplumber cannot OCR scanned images natively; StructOCR processes scanned PDFs, JPG, PNG, and WebP out of the box
- •Output Modes: `mode=tables` (tables only), `mode=json` (structured key-values / custom schema), `mode=auto` (both)
- •Custom Schema Support: Accepts a simple field list (`["field_a","field_b"]`) or a JSON Schema object
- •Multi-Page Stitching: Automatic cross-page continuation stitching across up to 20 pages per request (up to 10 MB upload)
- •Privacy: Strict Zero Data Retention (in-memory processing; `raw_response: null`)
- •Pricing: 2 credits per succeeded page; failed pages are refunded automatically
Key Features
- •Solves empty-list failures on scans: No more blank `extract_tables()` responses when customers upload copier scans or phone PDFs.
- •Eliminates brittle `table_settings` tuning: Handles borderless columns and wrapped descriptions without per-template line tolerances.
- •Strict JSON output for downstream APIs: Extract header metadata into `custom_data` while keeping line-item tables in `document.tables[]`.
- •Predictable cost & auto-refunds: Start with 200 permanent free credits (100 PDF pages) with no monthly subscription lock-in.
Example Combined JSON + Stitched Table Response (Synthetic Specimen)
Synthetic `mode=auto` response returning both user-defined `custom_data` fields and a stitched multi-page table.
{
"success": true,
"mode": "auto",
"document": {
"summary": {
"document_type": "bank_statement",
"title": "Business Checking Statement",
"language": "en"
},
"fields": {
"bank_name": "Northstar Commercial Bank"
},
"tables": [
{
"id": "table_1",
"title": "Account Activity",
"page_range": [
1,
2
],
"stitched": true,
"headers": [
"Date",
"Description",
"Debit",
"Credit",
"Balance"
],
"rows": [
[
"2026-10-03",
"ACH Deposit - Client Retainer",
"",
"8,500.00",
"24,120.40"
],
[
"2026-10-05",
"Cloud Hosting Renewal",
"640.00",
"",
"23,480.40"
]
]
}
]
},
"custom_data": {
"statement_period": "2026-10-01 to 2026-10-31",
"account_holder": "Redwood Logistics LLC",
"currency": "USD",
"opening_balance": "15,620.40",
"closing_balance": "23,480.40"
},
"pages": [
{
"page": 1,
"status": "ok",
"tables_found": 1
},
{
"page": 2,
"status": "ok",
"tables_found": 1
}
],
"usage": {
"page_count": 2,
"pages_processed": 2,
"pages_succeeded": 2,
"credits_per_page": 2,
"credits_charged": 4
}
}Frequently Asked Questions
Can I keep pdfplumber for fast digital PDFs and only call StructOCR on scans?
Yes. Many Python teams run a quick check with pdfplumber to see if pages contain embedded text; if text is missing or table extraction returns misaligned columns, they route the raw PDF bytes to POST /v1/pdf-extract.
How do I extract both header fields and line-item tables in one request?
Set mode=auto and pass your target fields via the schema form field (either a flat JSON array like ["po_number","total"] or a JSON Schema object). StructOCR returns custom_data alongside document.tables[].
What if my scanned PDF is longer than 20 pages?
Each request supports up to 20 selected pages (within the 10 MB upload limit). For longer files, send sequential page ranges such as pages=1-20 and pages=21-40.
Does StructOCR retain sensitive financial PDFs?
No. POST /v1/pdf-extract operates under strict zero data retention—files are processed in memory only and usage logs record raw_response: null.
You May Also Like
Related tutorials, platform guides, and comparisons
Convert PDF to JSON in Java – Scanned PDF & Schema OCR API
Convert scanned or digital PDFs into typed JSON in Java 17+ and Spring Boot via POST /v1/pdf-extract. Supports 10 MB multipart uploads, custom JSON schemas, and stitched tables.
Tabula Alternative for Scanned & Multi-Page PDF Tables
Replace Tabula and tabula-py without Java/JVM dependencies. Extract scanned, borderless, and multi-page PDF tables into stitched CSV, Excel, and JSON via POST /v1/pdf-extract.
Convert PDF to JSON in PHP & Laravel – Custom Schema OCR API
Convert scanned and digital PDFs to structured JSON in PHP 8+ and Laravel using CURLFile and POST /v1/pdf-extract. Supports custom JSON schemas and 10 MB binary uploads.
Extract Table from PDF to CSV in C# & .NET – Scanned PDF OCR API
Convert scanned and borderless PDF tables into RFC-4180 UTF-8 CSV files in C# / .NET 8+ using POST /v1/pdf-extract with automatic multi-page table stitching.
Extract Table from PDF to CSV in PHP & Laravel – PDF Table OCR API
Convert scanned and digital PDF tables into Excel-ready UTF-8 CSV files in PHP 8+ using CURLFile, fputcsv, and POST /v1/pdf-extract.
Pennsylvania Driver License PDF417 API
Decode the PDF417 barcode on the back of a Pennsylvania driver license or State ID and return normalized AAMVA fields as structured JSON.
Bulgaria Lichna karta (Лична карта) OCR Python SDK
Python Tutorial: Automate KYC in Bulgaria. Extract Cyrillic/Latin text, EGN (ЕГН), and read the MRZ from Lichna karta using StructOCR Python SDK.
Colombia Cédula OCR Python SDK
Python Tutorial: Automate KYC in Colombia. Extract data from the Colombian Cédula de Ciudadanía using StructOCR Python SDK. Supports NUIP extraction and complex address parsing.
Chile Cédula OCR Python SDK
Python Tutorial: Automate KYC in Chile. Extract data from the Chilean Cédula de Identidad using StructOCR Python SDK. Supports RUN/RUT extraction and native Spanish text parsing.
Brazil CIN OCR Python SDK: Extract CPF & MRZ
Python Tutorial: Automate KYC in Brazil. Extract Portuguese text, CPF numbers, and read the MRZ from the new CIN using the StructOCR Python SDK.
Camelot PDF Alternative for Borderless & Scanned Tables
Replace camelot-py without Ghostscript or OpenCV dependencies. Extract borderless, scanned, and multi-page PDF tables into Excel, CSV, and JSON via POST /v1/pdf-extract.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Add Receipt OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR receipt API into a Replit application. Build expense tracking and receipt scanning tools using Replit Agent and Secrets.
Add VIN OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR VIN scanner API into a Replit application. Build automotive and fleet tools using Replit Agent and Secrets.
Single-Page MRZ SDKs vs. Dual-Page Indian KYC API
Why traditional MRZ scanners fail at full Indian Passport verification, and how to process both the front identity page and the back address page in a single API call.
Template-Based OCR vs. StructOCR API for Invoice Processing
Why traditional zonal/template-based OCR fails at processing vendor invoices, and how layout-agnostic AI APIs instantly extract line items and totals.
Tesseract & PassportEye vs. StructOCR Passport API
A technical evaluation for developers deciding between open-source MRZ scanners and a dedicated cloud-based Passport OCR API.
Tesseract OCR vs. StructOCR API for ISO 6346 Container Numbers
A technical comparison for developers evaluating open-source Tesseract vs. a dedicated cloud API for extracting shipping container numbers.
From tutorial to production in 5 minutes.
You've seen the code. Now get your API key, grab your 200 free credits, and see it work with your own images. No credit card required.