Extract data from PDF Forms via PHP

Extract user data fields from fillable PDF document. Use Aspose.PDF for PHP via Java to modify PDF files programmatically

How to Extract data from PDF Forms using PHP via Java Library

In order to extract data from PDF Forms (Acroforms) in PDF file, we’ll use Aspose.PDF for PHP via Java API which is a feature-rich, powerful and easy-to-use document manipulation tool in php-java. Install Tomcat 9.0 version on any location, add Aspose.PDF.war, for more details check the GitHub page.

How to Extract AcroForm in PDF using PHP


To try the code in your environment, you need Aspose.PDF for PHP via Java.

  1. Load PDF in an instance of Document class.
  2. Get values from all fields using Document.Form class.
  3. Analyze names and values if needed.
  4. Load PDF in an instance of Document class
  5. Get values from all fields using Document.Form class

Extract data from PDF Forms - PHP

This sample code shows how to Extract data from PDF Forms in PDF using PHP

// Open a document
$document = new Document($inputFile);

// Get a field
$textBoxField = $document->getForm()->get("textbox1");

// Get the field name
$responseData = "PartialName: " . $textBoxField->getPartialName();

// Get the field value
$responseData = $responseData . " Value: " . $textBoxField->getValue();
$document->close();