Forms · PHP

Create and fill PDF forms in PHP

Build interactive AcroForm fields from PHP (text inputs, checkboxes, radio groups and dropdowns) with generated appearance streams, then fill and flatten them later. No NeedAppearances hack required.

Last updated: 2026-06-29

Why PHP needs this

Onboarding packets, consent sheets and government applications are interactive PDF forms, and the usual PHP answer (pdftk for filling, a viewer hack for display) is brittle and adds yet another binary to the stack.

rust-pdf authors a complete AcroForm with an appearance stream generated for every widget, so text fields, checkboxes, radio groups and dropdowns render correctly in every viewer without the NeedAppearances flag. Field names support dotted hierarchy, and an existing form can be filled by name and flattened into static content.

Both authoring and filling run in-process from a Laravel controller or queued job: load with EditableDoc, set fields, flatten and stream the result, with no pdftk to shell out to. composer require brings in the binding and ext-ffi bridges the native core, keeping the whole flow inside PHP.

  • Text fields, checkboxes, radio groups and dropdowns with generated appearance streams.
  • Hierarchical dotted field names for grouped data.
  • Fill an existing form and flatten it into non-editable content.

Build a form in PHP with rust-pdf

Bring in the package with Composer, then call the same idiomatic API every binding shares. The form-building snippet below is real PHP from the reference docs.

composer require rust-pdf/rustpdf

PHP
$doc = new Document();
$doc->addPage()
    ->textField('applicant.name', 0, [72, 700, 320, 720], '')
    ->checkbox('agree', 0, [72, 660, 88, 676], false)
    ->dropdown('plan', 0, [72, 620, 240, 640],
               ['Starter', 'Pro', 'Enterprise'], 1)
    ->radioGroup('billing', 0, [
        [[72, 580, 88, 596], 'monthly'],
        [[140, 580, 156, 596], 'annual'],
    ], 1)
    ->save('form.pdf');
Validated by: qpdfmutool

Form authoring and filling are part of the free PHP tier. No license token required.

The complete forms API is in the PHP documentation.

Forms in PHP: FAQ

Do the form fields render without NeedAppearances in PHP?

Yes. rust-pdf generates an appearance stream for every field, so checkboxes, text and choices display correctly in all viewers without the NeedAppearances workaround.

Can I fill an existing form in PHP?

Yes. Load the PDF, set text fields, checkboxes, radios and dropdowns by name, and optionally flatten the form so the values become permanent static content.

Is form authoring free?

Yes. Creating, filling and flattening AcroForm fields is part of the free tier in PHP.

Can I fill an uploaded form in a Laravel controller and flatten it?

Yes. Load the PDF with EditableDoc, set each field by its (possibly dotted) name, then flatten so the values become static content before you stream or store the file. It runs in the FPM request or a queued job, with no pdftk fill_form step to shell out to.

Automate PDF form workflows from PHP

One Rust core, the same forms in every language. Authoring, filling and flattening are free. You license only corporate features like PDF/A, signing and encryption.