PHP code example of eureka2 / acroforms

1. Go to this page and download the library: Download eureka2/acroforms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

eureka2 / acroforms example snippets




croforms\AcroForm;

$fields = [
    'text' => [ // text fields 
        'text_field1'    => 'value of text_field1',
        'text_field2'    => 'value of text_field2',
        ......
    ],
    'button' => [ // button fields
        'radio1' => 'value of radio1',
        'checkbox1' => 'value of checkbox1',
        ........
    ]
];

$pdf = new AcroForm('exemple.pdf', [
    'pdftk' => '/absolute/path/to/pdftk'
]);
$pdf->load($fields)->merge();
if (php_sapi_name() == 'cli') {
	file_put_contents("filled.pdf", $pdf->output('S'));
} else {
	$pdf->output('I', 'filled.pdf');
}



croforms\AcroForm;

$pdf = new AcroForm('example.pdf', [
    'fdf' => 'example.fdf',
    'pdftk' => '/absolute/path/to/pdftk'
]);
$pdf->merge();
if (php_sapi_name() == 'cli') {
    $pdf->output('F', 'filled.pdf');
} else {
    $pdf->output('I', 'filled.pdf');
    // or $pdf->output('D', 'filled.pdf');
}