How to Read PDF Files in PHP

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.

Instructions

    • 1

      Download the component. The component used in this example is XPDF. The software can be downloaded from the following address:
      foolabs.com/xpdf/download.html

    • 2

      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.

    • 3

      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";

    • 4

      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.' -');

Related Searches:

References

Comments

  • nikossumed Jun 18, 2010
    I have copied xpdf into local bin directory but I can't convert pdf file into text file. A have used this command : '$myPDFString = shell_exec('/usr/local/bin/pdftotext '.$path.' -');'. Is there something I missed?

You May Also Like

  • How to Merge PDF Files With PHP

    A common operation required on many systems is the merging, or combining, of multiple PDF files into one PDF document. PHP does...

  • Problems Reading PDF Files

    Problems Reading PDF Files. The hyper text markup language (HTML) which is used to produce web sites and web pages on the...

  • How to Upload PDF Files in PHP

    PHP has an upload function that handles uploading files to the web server. Upload PDF files to display on your website to...

  • How to Read a File in PHP

    Reading the contents of a file is an important part of dynamic Web scripting as well as command-line scripting. PHP allows you...

  • How to Read File Contents into a String in PHP

    PHP provides several methods to use the contents of a file in a script. They all have certain steps in common. These...

  • How to Create PDF Files in PHP

    PDF is one of the most popular electronic document formats due both to its safety and integrity of varying multimedia file types...

  • How to Read MS Office Files in PHP

    Microsoft Office documents are common formats used on the Web and on desktop machines. The PHP languages provides you with dynamic tools...

  • How to Change a PHP Form to PDF

    A Portable Document Format (PDF) creation tool is required to change and convert documents and Web pages to PDF. The industry standard...

  • How to Open a PDF File in PHP

    PHP is a scripting language, often used by web developers to program dynamic websites. There are many PDF functions in the PHP...

  • How to Read From PDF File

    The free Adobe Reader application allows users to view and print files created in the Portable Document Format. The program also offers...

Related Ads

Featured