Chaminda Chanaka
Chaminda Chanaka

Reputation: 190

Php Pdf Parser read content showing as a two lines. need to fix it

I used pdfparserto read PDF content. but one address line showing as a two line. in that time it is showing as a two new lines. i want to get that full address as a one line. pdf files are dynamic. according to the address length it is showing as a multiple lines.

I need proper solution to read that contents as a one line. i will attach that PDF address line here for reference. enter image description here

I think you can understand my requirement.

**my pdf read code is **

$fileName = basename($_FILES["file"]["name"]); 
$fileType = pathinfo($fileName, PATHINFO_EXTENSION); 

// Allow certain file formats 
$allowTypes = array('pdf'); 
if(in_array($fileType, $allowTypes)){ 
   // Include autoloader file 
   include 'vendor/autoload.php';
             
   // Initialize and load PDF Parser library 
   $parser = new \Smalot\PdfParser\Parser(); 
             
   // Source PDF file to extract text 
   $file = $_FILES["file"]["tmp_name"]; 
             
   // Parse pdf file using Parser library 
   $pdf = $parser->parseFile($file); 
             
   // Extract text from PDF 
   $text = $pdf->getText(); 
             
   // Add line break 
   $pdfText = nl2br($text);
}else{ 
  $statusMsg = '<p>Sorry, only PDF file is allowed to upload.</p>'; 
} 

After read pdf content it is showing like this

enter image description here

How can i get related content as a one line

Upvotes: 0

Views: 927

Answers (1)

Manthan Jadhav
Manthan Jadhav

Reputation: 1

$pdfText = nl2br($text); replace this line with $pdftext = str_replace("\t","insert here br tag",$text);

Upvotes: 0

Related Questions