How to search a section in a PDF remotely?

2

Is there a way for me to search a snippet, or a word in a PDF that is on the internet? I searched the CURL, some libraries, but found nothing. More or less this way:

I have a site and in it the guy would insert a name for example: John. After this the script of my site would check if inside the file: link there is the name João, and I would return if it exists or not.

Can you do this? Does anyone know of any library or can you give me a map?

    
asked by anonymous 03.05.2015 / 18:01

1 answer

2

The link library allows you to grab text from PDF files.

$url = 'http://www.bu.ufsc.br/ArtigoCientifico.pdf';
$nome = 'João';

$parser = new \Smalot\PdfParser\Parser();

$pdf = $parser->parseContent(file_get_contents($url));
$text = $pdf->getText();

if (strpos($text, $nome) !== false) {
    // achou o nome
}
    
04.05.2015 / 03:58