How to Flatten PDF Forms: CLI Tool Guide
What Does Flattening a PDF Form Actually Do?
Flattening a PDF form converts all interactive form fields, including text fields, checkboxes, dropdowns, and barcode fields, into permanent, non-editable PDF page content. The form data and layout are baked into the page itself. The resulting document has no live form fields: it looks identical to the filled form but cannot be edited, and it renders correctly in any PDF viewer without requiring XFA support.
Flattening is the correct step when a completed form needs to be archived, submitted for regulatory review, or delivered to a recipient who should not be able to modify it. It is also the required step for any XFA form that needs to enter a PDF/A-compliant archiving workflow, since XFA is not permitted in PDF/A.
Why XFA Forms Need Special Flattening Treatment
Flattening an AcroForm is straightforward for most PDF tools. AcroForms use standard PDF marking operators for field rendering, so any library that can read PDF can convert fields to static content.
XFA forms, especially dynamic XFA, are a different problem. Dynamic XFA has no PDF-based page content at all. The entire layout is calculated by the XFA rendering engine at open time. Flattening a dynamic XFA form correctly requires the SDK to first run the full XFA rendering pass, including layout calculation and field appearance generation, and then convert that rendered output to static PDF content.
SDKs without a proper XFA rendering engine will produce blank output, incorrect field positions, or missing content when flattening dynamic XFA. PDF Forms Flattener and Forms Extension are both built on the Adobe PDF Library with full XFA rendering support, which means flattened output matches what users see in Acrobat Desktop.
Using PDF Forms Flattener: Command-Line Basics
PDF Forms Flattener is a standalone command-line tool. You run it from a terminal, a shell script, or a scheduled job. No coding is required. The basic invocation specifies an input file and an output file:
pdfformsflattener --input completed-form.pdf --output flattened-form.pdf
For batch processing, you can point the tool at a directory:
pdfformsflattener --input ./forms-inbox/ --output ./forms-archive/
Additional parameters control behavior for specific form types, annotation handling, and output options. Refer to the PDF Forms Flattener documentation for the full parameter reference.
Need SDK-Level Control? When to Use Forms Extension Instead
PDF Forms Flattener is the right tool when flattening is the primary operation and you do not need to embed forms processing inside an application. For teams that need programmatic control over what happens to each form, or that need capabilities beyond flattening, Forms Extension is the right choice.
Forms Extension provides an API that developers use directly in their application code. It supports everything PDF Forms Flattener does, plus XFA-to-AcroForm conversion, form data import and export via FDF/XFDF/XML, form type detection, and barcode rendering with full preservation through flattening.
The decision is straightforward: if you are running forms through a CLI or script, use PDF Forms Flattener. If forms processing is a capability your application needs to perform programmatically, use Forms Extension.
Frequently Asked Questions
What is the difference between PDF Forms Flattener and Forms Extension?
PDF Forms Flattener is a standalone command-line tool for batch flattening XFA and AcroForms to static PDF. Forms Extension is a developer SDK that embeds full forms processing capabilities, including flattening, XFA-to-AcroForm conversion, and data import/export, directly into applications via an API.
Can PDF Forms Flattener handle dynamic XFA forms?
Yes. PDF Forms Flattener is built on the Adobe PDF Library with full XFA rendering support and handles both static and dynamic XFA forms correctly.
Is flattening the same as converting XFA to AcroForm?
No. Flattening converts an interactive form to a non-editable static PDF. Converting XFA to AcroForm produces an interactive AcroForm that users can still fill out. If you need the form to remain interactive after processing, use Forms Extension to convert to AcroForm rather than flatten.
Get a free trial of PDF Forms Flattener command line tool today.
Prefer an SDK? Check out Forms Extension!