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 All Field Types

This demo shows you how to fill in all field types depending on their class instances.

PHP
<?php

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

$files = [
    require 'data/dataset-1.php',
    require 'data/dataset-2.php',
    require 'data/dataset-3.php',
];

$dataId = displaySelect('Select file:', $files, true, 'displayValue');
$data = $files[$dataId];

$document = \SetaPDF_Core_Document::loadByFilename(
    $data['file'],
    new \SetaPDF_Core_Writer_Http('filled.pdf', true)
);

$formFiller = new \SetaPDF_FormFiller($document);
$fields = $formFiller->getFields();

/** @var \SetaPDF_FormFiller_Field_AbstractField $field */
foreach ($fields as $field) {
    $fieldName = $field->getQualifiedName();
    if (!isset($data['values'][$fieldName])) {
        continue;
    }

    $field->setValue($data['values'][$fieldName]);
}

$document->save()->finish();
PHP
<?php

return [
    'displayValue' => 'lenstown/Order-Form-without-Signaturefield.pdf',
    'file' => $assetsDirectory . '/pdfs/lenstown/Order-Form-without-Signaturefield.pdf',
    'values' => [
        'Order Number' => '987654',
        'Date' => date('Y-m-d'),
        'Name' => 'Test Person',
        'Company Name' => 'Awesome Company',
        'Adress' => 'Examplestreet 1',
        'City' => 'Exampleria',
        'Zip Code' => '12345',
        'State' => '-',
        'Country' => 'Orasiania',
        'Phone' => '+12 3456 7890',

        'Name_2' => 'Another Test Person',
        'Company Name_2' => 'A more Awesome Company',
        'Adress_2' => 'Examplestreet 2',
        'City_2' => 'Exampleria',
        'Zip Code_2' => '12345',
        'State_2' => '-',
        'Country_2' => 'Orasiania',
        'Phone_2' => '+12 7890 3456',

        'Item-Number.0' => 'X1245',
        'Description.0' => 'Rotator',
        'Quantity.0' => '10',
        'Unit-Price.0' => '15.00 €',
        'Amount.0' => '150.00 €',

        'Item-Number.1' => 'X4567',
        'Description.1' => 'Migrator',
        'Quantity.1' => '5',
        'Unit-Price.1' => '25.00 €',
        'Amount.1' => '125.00 €',

        'Subtotal' => '275.00 €',
        'Tax' => '52.25 €',
        'Freight Cost' => '10.00 €',
        'Total Amount' => '337.25 €'
    ]
];
PHP
<?php

return [
    'displayValue' => 'forms/Sunnysunday-Example.pdf',
    'file' => $assetsDirectory . '/pdfs/forms/Sunnysunday-Example.pdf',
    'values' => [
        'Balloons' => 'Yes',
        'How many balloons' => '10',
        'Balloon color' => ['red', 'green'],
        'Favorite Cake' => "Apple Cake with cream.\nOr something with fancy chocolate!",
        'Pets' => 'Yes',
        'Pet kind' => 'Dog',
        'Pet name' => 'Alec',
        'Arrival' => '3pm',
        'Departure' => '9pm',
    ]
];
PHP
<?php

return [
    'displayValue' => 'forms/Customizer-Example.pdf',
    'file' => $assetsDirectory . '/pdfs/forms/Customizer-Example.pdf',
    'values' => [
        'Core-Power' => '2 x 3 Ghz',
        'RAM' => '8192',
        'Graphics Device 1' => 'EAN67834654',
        'Graphics Device 2' => 3,
        'Harddisk 1' => 'SSD 10000GB', // the combo box is editable
        'Harddisk 2' => '1000GB',
        'Harddisk 3' => '750GB',
        'WLAN' => true,
        'Bluetooth' => true,
        'Card Reader' => true,
        'Feedback' => "It should be silent!\nAnd it should look fancy and modern!",
    ]
];