This page is a brief guide of VeryPDF Cloud OCR API. Developers can use VeryPDF Cloud OCR API to perform OCR (optical character recognition) in their applications. The following words introduce the basic usage of the API.
1. Register for an APIKEY | 2. Use Cloud API for OCR | 3. Frequently Asked Questions |
Before using VeryPDF Cloud OCR API, you need an APIKEY for authentication. You may refer the guide for registration of VeryPDF Cloud OCR API.
Use VeryPDF Cloud OCR API. This guide takes PHP code as demonstration to show you the GET/POST method to use VeryPDF Cloud OCR API.
Here are some demonstration URLs to illustrate the usage of VeryPDF Cloud OCR API.
http://online.verypdf.com/app/onlineapi/?apikey=XXXXXXXXXXXX&-format=2&-lang=1
&type=ocrsdk&inputfile=http://online.verypdf.com/images/tiff/testocr_0000.tif http://online.verypdf.com/app/onlineapi/?apikey=XXXXXXXXXXXX&-format=15&-lang=1
&type=ocrsdk&inputfile=http://online.verypdf.com/images/tiff/testocr_0000.tif http://online.verypdf.com/api/?apikey=XXXXXXXXXXXXX&app=ocr2&-format=1&-lang=1
&infile=http://online.verypdf.com/images/tiff/testocr_0000.tif http://online.verypdf.com/api/?apikey=XXXXXXXXXXXXX&app=ocr2&-format=2&-lang=1
&infile=http://online.verypdf.com/images/tiff/testocr_0000.tif http://online.verypdf.com/api/?apikey=XXXXXXXXXXXXX&app=ocr2&-format=7&-lang=1
&infile=http://online.verypdf.com/images/tiff/testocr_0000.tif http://online.verypdf.com/api/?apikey=XXXXXXXXXXXXX&app=ocr2&-format=9&-lang=1
&infile=http://online.verypdf.com/images/tiff/testocr_0000.tif http://online.verypdf.com/api/?apikey=XXXXXXXXXXXXX&app=ocr2&-format=15&-lang=1
&infile=http://online.verypdf.com/images/tiff/testocr_0000.tif http://online.verypdf.com/api/?apikey=XXXXXXXXXXXXX&app=ocr&outfile=out&lang=eng
&infile=http://online.verypdf.com/examples/cloud-api/test0002.tif http://online.verypdf.com/api/?apikey=XXXXXXXXXXXXX&app=ocr&outfile=out&lang=eng
&format&infile=http://online.verypdf.com/examples/cloud-api/test0002.tif http://online.verypdf.com/api/?apikey=XXXXXXXXXXXXX&app=ocr&outfile=out&lang=deu
&infile=http://online.verypdf.com/examples/cloud-api/german.tif http://online.verypdf.com/api/?apikey=XXXXXXXXXXXXX&app=ocr&format=1&dumpwordpos=1
&infile=http://online.verypdf.com/images/tiff/testocr_0000.tif http://online.verypdf.com/api/?apikey=XXXXXXXXXXXXX&app=ocr&outfile=out&lang=eng
&-format=2&infile=http://online.verypdf.com/images/tiff/testocr_0000.tif
The bold characters are options supported by VeryPDF Cloud OCR API:
Option -format and -lang has these values:
--------------------------------------------------------------------------- | ||
Option Value | Output Format | Remark |
--------------------------------------------------------------------------- | ||
-format=1 | RTF | default |
-format=2 | TXT (plaint text) | |
-format=7 | XLS (Excel) | |
-format=9 | DOC (Word) | |
-format=15 | HTML | |
-lang=1 | English | default |
-lang=2 | French | |
-lang=4 | German | |
-lang=8 | Italian | |
-lang=16 | Spanish | |
-lang=32 | Portuguese | |
--------------------------------------------------------------------------- |
If there is no value for an option, please use the format "option=NULL".
The following is a PHP code example to use VeryPDF Cloud OCR API to recognize text in an online image.
<?php
function http_post($url, $postfields) {
if (!function_exists("curl_init")) {
return "missing curl";
}
$c = curl_init();
curl_setopt($c, CURLOPT_URL,$url);
curl_setopt($c, CURLOPT_HEADER, false);
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($c, CURLOPT_DNS_USE_GLOBAL_CACHE, false);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
$http_code = 0;
$error = "";
$response = curl_exec($c);
$http_code = curl_getinfo($c, CURLINFO_HTTP_CODE);
$error_str = curl_error($c);
$error_nr = curl_errno($c);
curl_close($c);
if ($error_nr != 0) {
echo "info1:error ".$error_nr;
}
else if ($http_code == 200) {
return $response;
} else {
echo "info2:error ".$http_code;
}
}
function ocrsdk()
{
$apikey = "XXXXXXXXXXXXXX";
$format = "1";
$infile = "http://www.impdf.com/temp/123.jpg";
$lang = "1";
$url = "http://online.verypdf.com/app/onlineapi/";
$postfields = "apikey=" . $apikey . "&-format=". $format ."&inputfile=". $infile ."&-lang=". $lang . "&type=ocrsdk";
$out = http_post($url, $postfields);
echo $out;
}
ocrsdk();
?>
In the above demonstration code, the recognized text will be saved as RTF and returned by variable OUT. Save the returned data to disk with the corresponding extension name ".rtf", and then the text in the demonstration image is recognized and saved in a RTF file.
Sever reply
Successful process:
HTTP header status code: 200
Return created html, rtf, doc, xls, or txt file as response.
Error:
If error occurs, VeryPDF Cloud server will return standard error codes to indicate the error types.
Q: Is your VeryPDF Cloud OCR API using open source Tesseract OCR engine? | |
A: No. VeryPDF Cloud OCR API uses an OCR engine developed by VeryPDF. | |
Q: Can VeryPDF Cloud OCR API retain document formats and layouts? | |
A: Yes, of course. VeryPDF Cloud OCR API supports output files in formats of html, rtf, doc, and xls (retaining text formats and page layouts). It also support plain text output files. Textual PDF format will be supported soon. | |
Q: Can VeryPDF Cloud OCR API recognize text in low resolution images? | |
A: Currently VeryPDF Cloud OCR API does better to images of resolution higher than 150 DPI. And VeryPDF is working hard to improve the OCR effect to low resolution images (e.g., 72 or 96 DPI for screen snapshots). | |
Q: Does VeryPDF Cloud OCR API support multipage TIFF image recognition? | |
A: Yes. VeryPDF Cloud OCR API can recognize all pages in a multipage TIFF image. VeryPDF uses page count to calculate usage of server resources. | |
Q: Can I use VeryPDF Cloud OCR API after I subscribe VeryPDF Cloud API Platform? | |
A: Yes, VeryPDF Cloud OCR API is included inVeryPDF Cloud API Platform, so after you subscribe VeryPDF Cloud API Platform, you can use VeryPDF Cloud OCR API without pay any additional cost. |