phpdftk API Documentation

FormFiller
in package

FinalYes

Fill interactive PDF form fields (AcroForm).

Uses incremental updates to preserve the original PDF structure, existing signatures, and other content.

Usage: FormFiller::open('form.pdf') ->fill('name', 'Jane Doe') ->check('subscribe') ->select('country', 'Canada') ->save('filled.pdf');

Table of Contents

Methods

check()  : self
Check or uncheck a checkbox field.
fill()  : self
Set the value of a text or choice field.
fillMany()  : self
Fill multiple fields at once.
getFieldInfo()  : FieldInfo|null
Get detailed information about a specific field.
getFieldNames()  : array<int, string>
Get all field names in the form.
getFieldValues()  : array<string, string|null>
Get all field values as an associative array.
getPageCount()  : int
getReader()  : PdfReader
getVersionWarnings()  : array<int, string>
hasField()  : bool
Check whether a field exists in the form.
open()  : self
openString()  : self
save()  : void
select()  : self
Select an option in a choice field.
toBytes()  : string

Methods

check()

Check or uncheck a checkbox field.

public check(string $fieldName[, bool $checked = true ]) : self
Parameters
$fieldName : string
$checked : bool = true
Return values
self

fill()

Set the value of a text or choice field.

public fill(string $fieldName, string $value) : self
Parameters
$fieldName : string
$value : string
Return values
self

fillMany()

Fill multiple fields at once.

public fillMany(array<string, string> $values) : self
Parameters
$values : array<string, string>

Field name => value

Return values
self

getFieldInfo()

Get detailed information about a specific field.

public getFieldInfo(string $name) : FieldInfo|null
Parameters
$name : string
Return values
FieldInfo|null

getFieldNames()

Get all field names in the form.

public getFieldNames() : array<int, string>
Return values
array<int, string>

getFieldValues()

Get all field values as an associative array.

public getFieldValues() : array<string, string|null>
Return values
array<string, string|null>

getPageCount()

public getPageCount() : int
Return values
int

getVersionWarnings()

public getVersionWarnings() : array<int, string>
Return values
array<int, string>

hasField()

Check whether a field exists in the form.

public hasField(string $name) : bool
Parameters
$name : string
Return values
bool

open()

public static open(string $path[, string $password = '' ]) : self
Parameters
$path : string
$password : string = ''
Return values
self

openString()

public static openString(string $pdfBytes[, string $password = '' ]) : self
Parameters
$pdfBytes : string
$password : string = ''
Return values
self

save()

public save(string $path) : void
Parameters
$path : string

select()

Select an option in a choice field.

public select(string $fieldName, string $option) : self
Parameters
$fieldName : string
$option : string
Return values
self

toBytes()

public toBytes() : string
Return values
string

        
On this page

Search results