Fill PDF AcroForms with PHP


Fill in existing PDF forms with PHP

Create Individual Field Appearances

In normal situations the SetaPDF-FormFiller component will render a PDF form fields appearance for you. This rendering process is limited to default PDF form field types which are very limited in view to their layout capacities.

As already shown in the demo "Fill field with an Image" it is possible to create a field appearance manually and pass it to the field instance. This demo will go a step further and will get the appearance information from a JSON string that is defined as a text fields value. The dynamic data (in this case simple text strings) will be rendered based on this information.

At the end the form field appearances will get flattened to the pages content, so that they become part of the page itself and are not displayed through an widget annotation. The result will be a flat PDF document without PDF form fields.

The appearance in this demo is created with tFPDF. For sure this could be any PDF generation PHP class or library - it's just a demo.

This demo is actually limited to "text" but it should give you a clue about what you can create with this logic. A text can be configured e.g. like this:

    "type": "text",
    "fontFamily": "helvetica",
    "fontStyle": "B",
    "fontSize": 5,
    "color": [200, 200, 200],
    "align": "C"

The script will create the field appearance based on this information. To get more details, simply check the script output below and/or open the example PDFs by simply double-clicking them.

Select a File


Or upload a file