Home » Php » How to use Amazon Textract with document like images, pdf with aws-sdk-php in laravel

How to use Amazon Textract with document like images, pdf with aws-sdk-php in laravel

Posted by: admin February 25, 2020 Leave a comment

Questions:

I am working on AWS textract to extract text, form and tables from document like PDF and Image . If anyone has a solution with AWS sdk php, please share your answer with me.

$image = $request->file('bill_file');
$imagePath = $image->getPathName();
$fp_image = fopen($imagePath, 'rb');
$image = fread($fp_image, filesize($imagePath));
fclose($fp_image);
$client = new TextractClient([
'version'     => '2018-06-27',
'region'      => 'XXXXXXXXX',
'credentials' => [
'key'    => 'XXXXXXXXXXXXXXXXXX',
'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
]

]);
$options = [
'Document' => [
'Bytes' => $image
],
'FeatureTypes' => ['FORMS','TABLES'], 
];
$result = $client->analyzeDocument($options);
$blocks = $result['Blocks'];

this code gave me text, line, table table cell and forms

how to print table with cell with text and line, i am using laravel 5.7

How to&Answers: