How to Flatten PDF Forms in Batch: A Step-by-Step Guide

How to Flatten PDF Forms in Batch: A Step-by-Step Guide

Published June 17, 2026

If you are a developer or IT admin who needs to flatten PDF forms in batch -- AcroForms, static XFA, or dynamic XFA -- this guide walks through the full workflow using PDF Forms Flattener from the command line.

By the end, you will have run your first flatten, processed a directory of PDFs, imported data before flattening, and seen how to convert XFA form fields to AcroForm. No Acrobat required. No SDK integration needed.

 

What You Need Before You Start

A PDF Forms Flattener license or free trial key. The installer for your operating system: .exe for Windows, .bsx for Linux. One or more PDF files with form fields to test against.

PDF Forms Flattener runs on Windows and Linux. There is no macOS version.

 

Step 1: Install PDF Forms Flattener

On Windows, run the .exe installer and follow the prompts. When asked for your activation key, paste the key you received from Datalogics.

On Linux, run the .bsx installer from your terminal. Mark it executable first if needed:

chmod +x PDFFormsFlattener.bsx

./PDFFormsFlattener.bsx

Paste your activation key when prompted.

After installation, verify the tool is accessible by running it without arguments. You should see the help output listing available parameters.

 

Step 2: Flatten a Single PDF

The basic flatten command takes an input file, an output path, and the flatten flag:

PDFFormsFlattener --input
    input.pdf --output output.pdf --flatten true

This flattens all interactive form fields in input.pdf and writes the result to output.pdf. The original file is not modified.

What the output contains: all data that was in the form fields is now permanent text or images on the page. The form fields themselves are gone. The PDF is static and non-editable.

Try opening the output file in a PDF viewer. The document should look identical to the original, but clicking on a form field area will not activate an input box.

 

Step 3: Batch Process a Directory of PDFs

To process multiple files in one pass, point the input flag at a directory instead of a file:

PDFFormsFlattener --input
    /path/to/forms/ --output /path/to/output/ --flatten true

PDF Forms Flattener processes every PDF in the input directory and writes flattened copies to the output directory. The output filenames match the input filenames.

The output directory must exist before you run the command. Create it first if it does not.

This is the primary use case for automated pipelines: drop a batch of incoming forms into an input directory, run the flatten command as part of your processing script, and retrieve the static outputs from the output directory.

 

Step 4: Import Data Before Flattening

A common workflow is to populate a PDF form programmatically from an external data source, then flatten it immediately. PDF Forms Flattener handles both steps in a single command.

For AcroForms, use an FDF, XFDF, or XML data file:

PDFFormsFlattener --input form.pdf --output output.pdf --import data.xml --flatten true

For XFA forms, use an XFD, XDP, or XML data file:

PDFFormsFlattener --input xfa-form.pdf --output output.pdf --import data.xfdf --flatten true

The tool imports the data into the form fields, then immediately flattens the populated form into the output PDF. The result is a static PDF containing the imported data as permanent page content.

This populate-then-lock workflow is common in document generation scenarios: pull records from a database, populate a form template, flatten, and archive or distribute.

 

Step 5: Export Data Before Flattening

If you need to capture form data before removing the fields, use the export parameter first:

PDFFormsFlattener --input form.pdf --export data.xml

This writes the current field values to an XML file without modifying the PDF. You can then process the data file separately, push it to a database or CRM, and flatten the PDF as a second step.

Export format options: FDF, XFDF, XML for AcroForms; XFD, XDP, XML for XFA.

 

Step 6: Convert XFA to AcroForm Instead of Flattening

If your XFA form is still in active use and you need to preserve interactivity, converting the XFA fields to AcroForm is an alternative to flattening:

PDFFormsFlattener --input xfa-form.pdf --output acrof-output.pdf --convert true

The output PDF contains AcroForm fields in place of the XFA fields. The form remains interactive and opens correctly in any PDF viewer that supports AcroForms, which includes Chrome, Firefox, mobile viewers, and all modern PDF tools.

Note that complex dynamic XFA behaviors (conditional field visibility, dynamic layout expansion) may not be fully preserved in the AcroForm output, as AcroForms do not support every XFA feature. Test your output forms carefully for complex form logic.

 

Scripting PDF Forms Flattener into an Automated Pipeline

Because PDF Forms Flattener is a command-line tool, it integrates into any scripted workflow that can invoke a shell command. Common integration patterns include:

Cron jobs on Linux servers that process a directory of incoming forms on a schedule.

CI/CD pipeline steps that flatten generated PDFs as part of a document generation build.

Python or Bash scripts that call PDFFormsFlattener as a subprocess after populating form data from a database.

Windows Task Scheduler tasks that run batch flattening overnight.

The tool is stateless and does not require a running service or daemon. You invoke it, it processes the files, and it exits. This makes it easy to slot into any workflow that can execute a shell command.

 

Where to Go Next

This tutorial covers the most common use cases. The full parameter reference, including annotation appearance generation options and advanced XFA handling flags, is in the PDF Forms Flattener documentation.

Ready to run your first flatten? Get your free trial key at PDF Forms Flattener.