read pdf with php and PDF2Text or pdf-to-text (spatie)

i´m traying to extract text from my PDF with class PDF2Text or spatie/pdf-to-text but i can´t to do… i´m traying first with:

PDF2Text

if($request->file('adjunto') != ""){

$fileName = $request->file('adjunto')[0]->getClientOriginalName();

$ext = pathinfo($fileName, PATHINFO_EXTENSION);

$name = $fileName;
$result = $request->file('adjunto')[0]->storeAs('importaciones', $name, 'public');

$route = public_path('storage/importaciones/'.$name);

}else{
return "Error al subir fichero, consulte al administrador del sistema";
}

if ($ext == "pdf" || $ext == "PDF"){
$a = new PDF2Text();
$a->setFilename($route);
$a->decodePDF();
echo $a->output();
}else{

this else it´s for read CSV files. This code in block if PDF return empty result. And if i tray with

spatie library:

if($request->file('adjunto') != ""){

$fileName = $request->file('adjunto')[0]->getClientOriginalName();

$ext = pathinfo($fileName, PATHINFO_EXTENSION);

$name = $fileName;
$result = $request->file('adjunto')[0]->storeAs('importaciones', $name, 'public');

$route = public_path('storage/importaciones/'.$name);

}else{
return "Error al subir fichero, consulte al administrador del sistema";
}

if ($ext == "pdf" || $ext == "PDF"){
$text = (new Pdf())
->setPdf($route)
->text();
echo $text;
}else{

return this:

Error Output:
================

El sistema no puede encontrar la ruta especificada.
{"userId":60,"exception":"[object] (Spatie\PdfToText\Exceptions\CouldNotExtractText(code: 0): The command ""/usr/bin/pdftotext" "C:\xampp\htdocs\gdsRepository\public\storage/importaciones/VIZNAR.PDF" -" failed.

Exit Code: 1(General error)

Working directory: C:\xampp\htdocs\gdsRepository\public

Output:
================

if i tray with $fileName not $route

return this: local.ERROR: could not find or read pdf 'x.pdf' for my application i´m using laravel 5.6

mi PDF it´s:

enter image description here

i need ‘nombre'(name), ‘domicilio'(address), ‘telefonos'(phone)

in this link, have pdf example:

https://drive.google.com/file/d/14uz4_sRphrOVvziv6n6_illb778WkETl/view?usp=sharing

Thanks for read and thanks for help me, please

from Newest questions tagged laravel-5 – Stack Overflow https://ift.tt/3zUr1dO
via IFTTT

Related Posts

Codeigniter : Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE) in Laravel project

I’m getting following error: **Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE)** Note : It’s working in local but facing issue in production server. private…

Firebase receive notification while tab is active or on focus

What i want is to be able to perform an action when a user receives a notification while the browser is open and tab is active or…

Laravel’s alias loader does not find class

We have a legacy project that we cannot update and we need to make some changes in symfony’s Response.php in vendor. We have solved this by copying…

Laravel 5 – generic document management

I have a system where you can create different types of unique documents. For instance, one document is called Project Identified and this expects certain inputs. Originally,…

Laravel Nova limit the results in indexQuery

I ran intro a situation where I need to limit the results of a resource to only 3 results. To be more specific, based on the logged…

Auditoria en laravel 5.8 [closed]

Cómo puedo automatizar el registro de actividades de un usuario en laravel? Si un usuario ingresa a un app de laravel, debo guardar toda su actividas, a…

Leave a Reply

Your email address will not be published.