PHP code example of tyclipso / typdf
1. Go to this page and download the library: Download tyclipso/typdf 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/ */
tyclipso / typdf example snippets
$doc = new \Typdf\PdfDocument('/path/to/form.pdf');
// Inspect fields
foreach ($doc->getFields() as $name => $field) {
echo $field->name.' ('.$field->type->value.'): '.($field->value ?? 'empty')."\n";
}
// Fill fields
$doc->setFieldValue('firstName', 'Jane'); // text
$doc->setFieldValue('agreeToTerms', true); // checkbox
$doc->setFieldValue('gender', 'female'); // radio button
$doc->setFieldValue('country', 'DE'); // select/combo
// Save
$doc->save('/path/to/filled.pdf');
// or: $bytes = $doc->getContent();