PDF OCR to Text API Integration Guide
Learn how to integrate the PDF OCR to Text API with documented request parameters, response fields, error handling, and practical examples.
PDF OCR to Text API
Extract searchable text from scanned PDFs with PDF OCR to Text. Upload a PDF or provide a public link, then use page-level text in search, archives, and document workflows.
Try a scanned document
The two-page sample PDF contains images without selectable text. The live Demo recognizes this document and caches the result for 15 minutes.
curl --request POST 'https://api.gugudata.io/v1/imagerecognition/pdf2text?appkey=YOUR_APPKEY' --form 'file_url=https://gugudata.io/assets/demo/pdf2text-demo.pdf' --form 'lang=en'
For an upload, replace file_url with --form 'file=@document.pdf'. Send exactly one input. AppKey belongs in the query.
Parameters
| Field | Description |
|---|---|
file |
PDF upload, maximum 20 MiB and 50 pages |
file_url |
Public HTTP(S) PDF URL; use instead of file |
lang |
en (default), zh-CN, zh-TW, en+zh-CN, or en+zh-TW |
Choose Simplified Chinese (zh-CN), Traditional Chinese (zh-TW), or mixed English and Chinese as needed. English remains the default.
Response data
{
"resultText": ["GuGuData PDF OCR demo", "Second page document workflow"],
"text": "GuGuData PDF OCR demo\n\nSecond page document workflow"
}
The success envelope contains dataStatus and data; the example above shows data. Check HTTP status and dataStatus.statusCode are both 200.
resultText follows page order and retains empty strings for blank pages. text joins nonempty pages with two newlines. A document without recognizable text returns 422 rather than a successful empty result.
Limits and errors
| HTTP status | Meaning |
|---|---|
| 400 | Invalid or conflicting inputs or unsupported language |
| 401 / 403 | Authentication or authorization failure |
| 413 | File exceeds 20 MiB or 50 pages |
| 422 | Invalid, encrypted, unreadable PDF or rendering limit exceeded |
| 429 | Request rate limit reached |
| 502 | Download or OCR processing failed or timed out |
| 503 | Processing capacity or service unavailable |
Documents over 50 pages fail explicitly; they are not silently truncated. Use PDF Splitting for larger documents.
Quality and workflows
Use clear, upright scans with legible print and good contrast. Accuracy depends on scan quality. This API does not guarantee handwriting recognition, table structure, exact layout, or perfect accuracy. Review important values before acting on them.
Store recognized text alongside the original document for search and review. For PDFs with selectable text, consider PDF Parsing. For editable output, see PDF OCR to Word.