SetaPDF Demos

There seems to be a problem loading the components. Please check your PHP error logs for details!

Common issues could be that you missed to install the trial license or that you are using a trial version on an unsupported PHP version.

Fill Static XFA

This demo shows you how to fill a static XFA form.

A static XFA form has an XML package representing the XFA form and a standard AcroForm representation.

The SetaPDF-FormFiller component keeps both information in sync for you.

PHP
<?php

// load and register the autoload function
require_once __DIR__ . '/../../../../../bootstrap.php';

// get the document isntance
$document = \SetaPDF_Core_Document::loadByFilename(
    $assetsDirectory . '/pdfs/forms/xfa/CheckRequest.pdf',
    new \SetaPDF_Core_Writer_Http('static-xfa-form.pdf', true)
);

// now get an instance of the form filler
$formFiller = new \SetaPDF_FormFiller($document);

// solution A:
$xfa = $formFiller->getXfa();
if ($xfa === false) {
    echo "No XFA data found.";
}

// pass the data packet to the setData() method:
$xfa->setData('
<form1>
    <Name>Test Person</Name>
    <Title>Dr.</Title>
    <Deptartment>Sales</Deptartment>
</form1>
');
// sync the AcroForm fields
$xfa->syncAcroFormFields();

// solution B: Same as normal AcroForm fields
$fields = $formFiller->getFields();
// will overwrite the Title
$fields['form1[0].#subform[0].Header[0].Title[0]']->setValue('Prof.');
// ...

$document->save()->finish();