PHP code example of vluzrmos / ocrwebservice

1. Go to this page and download the library: Download vluzrmos/ocrwebservice library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vluzrmos / ocrwebservice example snippets


/*
 * USERNAME and LICENSE_KEY are strings, and both are provided by ocrwebservice.com.
 */
$ocr = new OCRWebService\OCRWebService(USERNAME, LICENSE_KEY);
$account = $ocr->getAccountInformation();

/*
 Returns an object AccountInformation which has a method ->toArray():
 [                                                  
   "AvailablePages" => 22,                          
   "MaxPages" => 25,                                
   "ExpirationDate" => "04/29/2016",                
   "LastProcessingTime" => "3/29/2016 10:42:13 AM", 
   "SubcriptionPlan" => "TRIAL",                    
   "ErrorMessage" => "",                            
 ]                                                  
*/

$account->getAvailablePages();
$account->getMaxPages();
//...

$account->availablePages; //same of getAvailablePages() method;
//...


/*
 * USERNAME and LICENSE_KEY are strings, and both are provided by ocrwebservice.com.
 */
$ocr = new OCRWebService\OCRWebService(USERNAME, LICENSE_KEY);

$document = $ocr->processDocument($pathToPdfOrImage, [
	'gettext' => 'true',
	'pagerange' => 'allpages',
	'language' => 'brazilian'
]);

//all options like described in http://www.ocrwebservice.com/api/restguide

// $document will be an instance of ProcessDocument, with that following methods:

$document->getOCRText(); //return ocr 
$document->toArray(); //return an array with all data 
//...