Fillable PDF Forms via PHP

Сreate fillable PDF acroforms. Use Aspose.PDF for PHP via Java to modify PDF files programmatically

How to Fill PDF Forms Using PHP via Java Library

In order to fill PDF Forms (Acroforms) in a PDF file, we’ll use Aspose.PDF 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.

How to Fill 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. Create a field in PDF file.
  3. Add field to the document.
  4. Save modified PDF

Fill AcroForm in PDF - PHP

This sample code shows how to Fill PDF forms in PDF using PHP

// Open document
$document = new Document($inputFile);
$page = $document->getPages()->get_Item(1);

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

// Modify field value
$textBoxField->setValue("Value to be filled in the field");
    
// Save updated document
$document->save($outputFile);
$document->close();