Reading a PDF file is becoming more necessary for programmers, as the use of these dynamic file types is growing. Reading PDF files requires an extra component added to the host server. This component is then called in the PHP file, enabling the compiler to read the content.
Download the component. The component used in this example is XPDF. The software can be downloaded from the following address:
Unzip the files from the download into the local bin directory of the web host. This bin directory needs to be a place where the PHP compiler has access to call the software's executable files.
Create a string with the path to the PDF file. Below is a string variable assigned the path of the PDF file to read.
$path = "c:\myFile.PDF";
Read the content of a file into another string variable. The following code retrieves the PDF file using the add-on installed in Step 2:
$myPDFString = shell_exec('/usr/local/bin/pdftotext '.$path.' -');
How to Convert HTML to PDF Using PHP
Other People Are Reading. How to Convert HTML & PHP to PDF; ... when you wish to edit the content of a...
How to Change a PHP Form to PDF
Other People Are Reading. How to Open a PDF Form Using PHP; ... PDF or Portable Document Format is a popular file...
How to Read PDF Files in Unix
The xPDF viewer is another PDF viewer available for the Unix operating system. Other People ... How to Read PDF Files in...
How to Convert PHP to PDF
Other People Are Reading. How to Convert PDF to JPG with PHP; How To: PDF to JPG on ImageMagick in PHP; Print...