Is There a Pdf Parser For PHP

Get content of PDF file in PHP

You can use PDF Parser (PHP PDF Library) to extract each
and everything from PDF's.

PDF Parser Library Link: https://github.com/smalot/pdfparser

Online Demo Link: https://github.com/smalot/pdfparser/blob/master/doc/Usage.md

Documentation Link: https://github.com/smalot/pdfparser/tree/master/doc

Sample Code:

<?php

// Include Composer autoloader if not already done.
include 'vendor/autoload.php';

// Parse pdf file and build necessary objects.
$parser = new \Smalot\PdfParser\Parser();
$pdf = $parser->parseFile('document.pdf');

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

?>

Regarding another part of your Question:

How To Convert Your PDF Pages Into Images:

You need ImageMagick and GhostScript

<?php
$im = new imagick('file.pdf[0]');
$im->setImageFormat('jpg');
header('Content-Type: image/jpeg');
echo $im;
?>

The [0] means page 1.

Read pdf files with php

Check out FPDF (with FPDI):

http://www.fpdf.org/

http://www.setasign.de/products/pdf-php-solutions/fpdi/

These will let you open an pdf and add content to it in PHP. I'm guessing you can also use their functionality to search through the existing content for the values you need.

Another possible library is TCPDF: https://tcpdf.org/

Update to add a more modern library: PDF Parser



Related Topics



Leave a reply



Submit