I am using spatie library with xpdf in laravel to fetch pdf information uploaded by user. pdftotext is working for me. I am seperating whatiwant
from pdf with colon
using preg_match function of php.
$re = '/\b:\s*\'\K[\w-]+/i';
$str = "Some text as: 'Nerad'";
if (preg_match($re, $str, $match)) {
echo $match;
}
Suppose my pdf contain same data with multiple times. Like I have one column with team_leader_name
. But there can be more than 1 or 2 team leaders for user.
and my data comes into array. i am just looping that array and getting my data with index[]
and storing into database.
But if i get same data with 2 times how to recognize them.
PDF demo:
Director's Data Director Name : ABC
Director Address : XYZ
Team leader Info
Team leader name : ghi
Team leader address : kji
Team leader name : asx
Team leader address : kji
Team leader name : plk
Team leader address : kji
Now i have to send director's data into separate table and team leaders data into separate table. Above pdf will convert into text and data will come in below format:
Array
(
[0] => Array
(
[0] => ABC
[1] => XYZ
[2] => ghi
[3] => kji
[4] => asx
[5] => kji
[6] => plk
[7] => kji
)
)
Now, I have this much info only. It will be ok If i am not having multiple data of same keywords from pdf. But what if i have duplications in pdf.Is there any other preg_match or other solution. Because my words before colon will not be changed.