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.

Why PHP needs this

PHP's classic libraries (TCPDF, FPDF) predate modern PDF and have no real PDF/A, no PAdES signatures and no AES-256, while the commercial alternatives are costly.

rust-pdf generates a full AcroForm with appearance streams baked in, so fields render correctly everywhere without relying on the viewer. Names support dotted hierarchy for grouped fields, and an existing form can be filled programmatically and flattened into static content.

  • 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

Install the package, then call the same idiomatic API every rust-pdf binding shares. The snippet below is real PHP code from the reference docs.

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

This is part of the free tier in PHP. No license required.

Full PHP reference in the 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.

Create and Fill PDF Forms in PHP

One Rust core, the same output across every language. Prototype for free, license the corporate features when you ship.