user2731506
user2731506

Reputation: 73

Reading PDF files in PHP or JS, then extracting the contents, by text ideally

I have a task of reading pdf files after an upload in the DB or n a folder,

What is the question here is : How to read PDF files in PHP or JS, JQuery, AJAX, Then i want to recuperate the datas to inject in a form fields.

There's a lot of infos to do this process with text files but pdf seems complicated. There is a PHP class for that ? I'm not used to classes in Php but with infos, it would lead me.

Thanks a lot for help!! Have a grreat one!

Upvotes: 2

Views: 1572

Answers (1)

Robin Woudstra
Robin Woudstra

Reputation: 76

I managed to do this using http://www.pdfparser.org/

I needed the specifications from a pdf file and get all the raw text. This is the code I used:

<?php
include 'pdfparser-master/vendor/autoload.php';
$parser = new \Smalot\PdfParser\Parser();
$pdf    = $parser->parseFile('specs.pdf');

$text = $pdf->getText();
echo $text;
?>

Upvotes: 2

Related Questions