Fill AcroForms

Contents
[ ]

PDF documents are wonderful, and really the preferred file type, for creating Forms.

Aspose.PDF for PHP via Java allows you to fill a form field, get the field from the Document object’s Form collection.

Let’s look at the following example how to resolve this task:


    // Load XFA form
    $document = new Document($inputFile);
    
    // Get names of XFA form fields
    $names = $document->getForm()->getXFA()->getFieldNames();
        
    // Set field values        
    $document->getForm()->getXFA()->set_Item($names[0],"Field 0");
    $document->getForm()->getXFA()->set_Item($names[1],"Field 1");
        
    // Save the updated document
    $document->save($outputFile);
    
    // Save modified PDF    
    $document->close();