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
How to Read PDF File using PHP
There are a variety of techniques to read PDF using PHP. I won't be using the code in here because it is not appropriate on the premise that we don't know what is your exact use case. But here are a few links that could help you out. In no particular order,
- FPDF: http://www.fpdf.org/
- FPDF is a PDF reader for PHP. The one below, is more like a converter.
- PDF TO HTML http://pdftohtml.sourceforge.net/
- Free PDF Document Importer: http://www.setasign.com/products/fpdi/about/
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 the content of a PDF with PHP?
I see two solutions here:
- converting your PDF file into something else before: text, html.
- using a library to do so and bad news here, most of them are written in Java.
https://whatisprymas.wordpress.com/2010/04/28/lucene-how-to-index-pdf-files/
Reading PDF file with php
How can you read a pdf file? If by read you mean to read characters in the pdf file then you need an OCR library to do the same. You can find different libraries like:
http://www.fpdf.org/
Reading PDF files in PHP
Yes, you can. Either install a command line script that can convert PDFs to text and execute this in PHP
$content = shell_exec('/usr/local/bin/pdftotext '.$filename.' -'); //dash at the end to output content
(source)
... or write a PHP function like this.
Related Topics
Replacing Accented Characters PHP
How to Call a PHP Function on the Click of a Button
Isset() and Empty() - What to Use
How to Delete a Line from the File With PHP
MySQLi Bind_Param() Expected to Be a Reference, Value Given
Convert Dot Syntax Like "This.That.Other" to Multi-Dimensional Array in PHP
PHP: Producing Relative Date/Time from Timestamps
Secure Random Number Generation in PHP
How to Find the Mime Type of a File With PHP
How to Enable Curl in PHP/Xampp
Using a .PHP File to Generate a MySQL Dump
How to Define a Class Property Value Dynamically in PHP
Strict Standards: MySQLi_Next_Result() Error With MySQLi_Multi_Query
Does PHP Have Short-Circuit Evaluation
Laravel: Error [Pdoexception]: Could Not Find Driver in Postgresql