ocr_file
Extract text from a local PDF or image, or save a searchable PDF, using OCR. Large documents return a document ID that you use to fetch the result later.
Instructions
OCR a local PDF or image with FastOCR and return its text or save a searchable PDF.
Uploads the file, runs OCR and waits up to 45 seconds. With output='text' the text is returned; text longer than 20,000 characters is cut, and the full text is written to output_path or to .ocr.txt next to the input file. With output='pdf' the searchable PDF is saved to output_path or to .searchable.pdf next to the input file. Either default file replaces an earlier result with the same name. Each processed page uses one page of the account's balance; an image is one page. Large documents take longer: then this returns a document id, and get_document with the same output fetches the result. Never call ocr_file again for that file, which bills it again.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to a local PDF, PNG, JPG, JPEG, GIF, WebP or BMP file. | |
| output | No | 'text' returns the extracted text; 'pdf' saves a searchable PDF with a text layer. | text |
| output_path | No | Optional absolute path for the result file. An existing file there is replaced. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |