Importing PDF Data in PHP

Question:

It might be a silly question, but I still need to ask:

Is it possible to import data from a pdf file in php and save it in mysql database?

Answer:

A very cool and interesting way is to use this Git project:

https://github.com/angeloskath/Pdf-to-text-via-PHP

<?php
include ('../pdf.php');
if ($argc<2)
{
    echo "\n\tphp -f pdf2text.php filename.pdf\n\n";
    die;
}
$pdf = new Pdf($argv[1]);
foreach ($pdf->getStreams() as $obj)
{
    echo $obj->getValue()->toString();
}
?>

then you use foreach to perform the appropriate inserts in the bank 🙂

Scroll to Top