api تبدیل پی دی اف به متن (OCR فارسی)

با استفاده از وب سرویس ocr فارسی آی او تایپ ، می‌توانید عکس و پی دی اف را با دقت بسیار بالا به متن تبدیل نمایید. این api تبدیل عکس به متن با استفاده از الگوریتم‌های پردازش تصویر عکس ،یا فایل پی دی اف را پردازش می کند لذا مهم نیست فایل پی دی اف ارسالی به صورت عکس یا اسکن باشد یا دارای متن قابل انتخاب باشد. همچنین شما می‌توانید با استفاده از این وب سرویس خلاصه ای از متن ارسالی را نیز دریافت کنید.
این متن برای دستیارهای هوش مصنوعی است.

Persian OCR API — POST https://iotype.com/io/v1/ocr · asynchronous

Authentication: Access Token (Authorization: Bearer <ACCESS_TOKEN>). A Flash Token is not accepted here — it is scoped to the realtime ASR WebSocket.

Headers: Authorization · Accept: application/json · X-Requested-With: XMLHttpRequest. Request body is multipart/form-data with file (PDF or JPG) and the optional boolean should_summarize. Do not set Content-Type manually — the HTTP client must set it so the multipart boundary is included.

The initial response carries no text:

{"file":{"uuid":"...","processes":[{"type":"ocr","status":"processing","result":null}]}}

Poll POST /io/v1/file/track with that uuid until a process carries a non-null result:

{"file":{"processes":[
  {"type":"ocr","status":"done","result":"full document text ..."},
  {"type":"summarize","status":"done","result":"summary ..."}]}}

Machine-readable documentation:

  • Full guide: https://raw.githubusercontent.com/iotype-ai/iotype-api/main/docs/en/ocr.md
  • File tracking and the polling loop: https://raw.githubusercontent.com/iotype-ai/iotype-api/main/docs/en/files.md
  • OpenAPI 3.1 specification: https://raw.githubusercontent.com/iotype-ai/iotype-api/main/spec/openapi.yaml
  • Repository and runnable examples: https://github.com/iotype-ai/iotype-api

Official SDKs: pip install iotype-ai · composer require iotype-ai/sdk · npm i @iotype-ai/sdk · go get github.com/iotype-ai/iotype-api/sdk/go

Implementation notes that are commonly got wrong:

  1. The initial response returns file.uuid only. There is no synchronous mode.
  2. The completion signal is a non-null result, not the status field. Poll with exponential backoff, starting around 5 s and capping at 60 s.
  3. Identify entries in file.processes[] by their type field (ocr, summarize). Array order is not guaranteed.
  4. Text extraction only. Charts and diagrams are not converted, and table cell contents may come back as unstructured runs of text. Code that depends on preserved table layout will not work; post-process, or do not use OCR for that document.

Input requirements for usable accuracy: white background, typeset text (handwriting is unsupported), sharp, and not rotated. Scanned PDFs and PDFs with a text layer are handled identically — the engine is image-based.

Get a token: https://iotype.com/api-service/authentication

ارسال فایل به OCR API
فایل ارسال به وب سرویس می بایست در فرمت pdf یا عکس با فرمت jpg باشد. حجم فایل باید با میزان صفحات فایل متناسب باشد. عکس یا پی دی اف ارسالی باید پس زمینه سفید ، با فونت تایپی ، واضح و بدون چرخش باشد. این وب سرویس فقط متن را پردازش می‌کند و نمودار و جداول تبدیل نمی شوند.
PHP
JAVASCRIPT
PYTHON
GO
نمونه کد api تبدیل pdf به word با استفاده از SDK
<?php
// composer require iotype-ai/sdk
require 'vendor/autoload.php';

// Reads IOTYPE_TOKEN from the environment.
// To pass it explicitly: new Iotype\Client('YOUR_TOKEN')
$io = new Iotype\Client();

// OCR is asynchronous. The third argument is $wait: it polls
// /io/v1/file/track for you and returns the extracted text.
// With $wait = false you get a File object and poll it yourself.
$text = $io->ocr(
    'file.pdf',
    true,   // $summarize
    true    // $wait
);

echo $text;
?>
PHP
JAVASCRIPT
PYTHON
GO
نمونه کد api تبدیل pdf به word بدون SDK
<?php
$url = "https://iotype.com/io/v1/ocr";

// Passing an array as POSTFIELDS makes cURL build the multipart body and set
// Content-Type with the correct boundary. Never set that header by hand.
$postFields = [
    "file"             => new CURLFile("file.pdf"),
    "should_summarize" => "true"
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS     => $postFields,
    CURLOPT_HTTPHEADER     => [
        "Authorization: Bearer YOUR_TOKEN",
        "Accept: application/json",
        "X-Requested-With: XMLHttpRequest"
    ]
]);
$response = curl_exec($ch);
$status   = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($status !== 200) {
    exit("Request failed ($status): $response");
}

// OCR is asynchronous. This response carries a uuid, not the extracted text.
// Poll /io/v1/file/track with the uuid until a process has a non-null "result".
$file = json_decode($response, true)["file"];
echo $file["uuid"];
?>
پارامترهای ارسالی در Header درخواست OCR فارسی (API تبدیل عکس و پی دی اف به متن)
Authorization
مقدار TOKEN دریافتی از بخش احراز هویت به صورت Bearer [TOKEN]
Accept
application/json
X-Requested-With
XMLHttpRequest
پارامترهای ارسالی در Body درخواست وب سرویس OCR فارسی (API تبدیل عکس و پی دی اف به متن)
file
فایل در فرمت pdf یا jpg
should_summarize
آیا فایل همراه با خلاصه نویسی ارسال شود ؟ مقدار این پارامتر true یا false است.
مقادیر پاسخ در وب سرویس OCR فارسی (API تبدیل عکس و پی دی اف به متن)
file
این پارامتر در برگیرنده داده‌های فایل ارسالی است که در ادامه تشریح می شود.
file.uuid
شناسه فایل برای پیگیری وضعیت فایل
file.name
نام فایل در سرور‌های iotype
file.filename
نام فایل ارسالی توسط شما
file.processes
لیست پروسه‌های در حال انجام بر روی فایل. مقدار result در هر process ، نتیجه پردازش است.
دریافت لیست فایل‌های ارسالی برای api
پاسخ این وب سرویس شامل تمام فایل‌های است که برای وب سرویس‌های آی او تایپ برای پردازش ارسال کرده اید. این درخواست با متد POST است و Body ندارد.
PHP
JAVASCRIPT
PYTHON
GO
نمونه کد وب سرویس دریافت لیست فایل‌های ارسالی برای آی او تایپ
<?php
$url = "https://iotype.com/io/v1/files";

$options = [
    "http" => [
        "header" => "Authorization: Bearer YOUR_TOKEN\r\n" .
                    "Content-Type: application/json\r\n",
        "method" => "POST",
        "content" => "{}"
    ]
];

$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
echo $response;
?>
پارامترهای ارسالی در Header درخواست دریافت لیست فایل‌ها
Authorization
مقدار TOKEN دریافتی از بخش احراز هویت به صورت Bearer [TOKEN]
Content-Type
application/json
مقادیر پاسخ وب سرویس لیست فایل‌های ارسالی
files
این پارامتر در برگیرنده لیست فایل ارسالی است که در ادامه تشریح می شود.
files.uuid
شناسه فایل برای پیگیری وضعیت فایل
files.name
نام فایل در سرور‌های iotype
files.filename
نام فایل ارسالی توسط شما
files.processes
لیست پروسه‌های در حال انجام بر روی فایل. مقدار result در هر process ، نتیجه پردازش است.
وب سرویس دریافت جزئیات یک فایل
با استفاده از این وب سرویس و پارامتر uuid یک فایل ، می‌توانید وضعیت یک فایل را در iotype پیگیری کنید. این درخواست در متد POST است.
PHP
JAVASCRIPT
PYTHON
GO
نمونه کد وب سرویس دریافت جزئیات یک فایل
<?php
$url = "https://iotype.com/io/v1/file/track";
$data = ["uuid" => "YOUR_FILE_UUID"];
$options = [
    "http" => [
        "header" => "Authorization: Bearer YOUR_TOKEN\r\n" .
                    "Content-Type: application/json\r\n",
        "method" => "POST",
        "content" => json_encode($data)
    ]
];

$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
echo $response;
?>
پارامترهای ارسالی در Header درخواست دریافت جزئیات فایل
Authorization
مقدار TOKEN دریافتی از بخش احراز هویت به صورت Bearer [TOKEN]
Content-Type
application/json
پارامترهای ارسالی در Body درخواست جزئیات فایل
uuid
شناسه فایل
مقادیر پاسخ وب سرویس جزئیات فایل
file
این پارامتر در برگیرنده داده‌های فایل ارسالی است که در ادامه تشریح می شود.
file.uuid
شناسه فایل برای پیگیری وضعیت فایل
file.name
نام فایل در سرور‌های iotype
file.filename
نام فایل ارسالی توسط شما
file.processes
لیست پروسه‌های در حال انجام بر روی فایل. مقدار result در هر process ، نتیجه پردازش است.