Extract PDF using PHP

How to extract text and images from PDF using Aspose.PDF for PHP via Java library

The most popular action with a Parser

How to parse PDF with Aspose.PDF for PHP via Java Library

To extract PDF files, we’ll use Aspose.PDF for .NET API, which is a feature-rich, powerful, and easy-to-use document manipulation API for php-java platform. Open NuGet package manager, search for Aspose.PDF and install. You may also use the following command from the Package Manager Console.

Parse PDF using PHP


You need Aspose.PDF library to try the code in your environment.

  1. Load the PDF with an instance of Document.
  2. Create a TextAbsorber object to extract text.
  3. Accept the absorber for all the pages.
  4. Get the extracted text
  5. Create a writer and open the file, write a line of text to the file

Extract PDF Files - PHP

This sample code shows how to extract PDF documents

Input file:

File not added

Output format:

PDF

Output file:


    // Create a new Document object from the input PDF file.
    $document = new Document($inputFile);

    // Create a new TextAbsorber object to extract text from the document.
    $textAbsorber = new TextAbsorber();

    // Extract text from the document.
    $textAbsorber->visit($document);

    // Get the extracted text content.
    $content = $textAbsorber->getText();

    // Save the extracted text to the output file.
    file_put_contents($outputFile, $content);

    $document->close();

About Aspose.PDF for PHP via Java API

Our .NET Library can combine a document from any supported download format to any supported save format. Aspose.PDF for .NET library provides fairly universal solutions that will help you solve the tasks of merging documents. Aspose.PDF supports the most significant number of popular document formats, both for loading and saving. Draw your attention to the fact that the current section describes only popular merges. The current page provides information about merging {{FILETYPE}} to {{FILERESULT}}. However, there are many combinations for merging your files. For a complete list of supported formats, see the section Supported File Formats.