PDF flatten keeps glyphs; XFA forms will not lock
Flattening bakes AcroForm field appearances into the page stream so values stop being editable while text stays selectable; XFA LiveCycle packets are not AcroForms and pdf-lib cannot draw them into the page.
Flattening bakes AcroForm field appearances into the page stream so values stop being editable while text stays selectable; XFA LiveCycle packets are not AcroForms and pdf-lib cannot draw them into the page.
PDF Form Flattener is a local pdf-lib pass. You drop a filled PDF, you see every field name and its current value, then flatten() writes those appearances into the page. The download is {name}-flat.pdf. The letters in the body stay letters. Search still works. Copy still works. The boxes stop being a form. That is the whole constraint. It is not a lock on XFA, and it is not a redaction.
Flatten bakes appearances and keeps text as text
AcroForm fields are widgets sitting on top of a page. Until you flatten, a viewer can still type into them. Flattening takes each field's appearance — the value you already filled — and draws it into the page content stream. After that, there is no widget to edit. The value is ordinary page content.
Because it is drawn as page content, the glyphs survive as text. Body copy, labels, the filled string: still selectable. That is the opposite of printing to PDF. Printing rasterises everything. Flattening keeps text as text and only bakes the field appearances. The file stays searchable; it just stops being a form.
You will see the field list first. Flattening a form you have not filled is how you lock empty boxes. No AcroForm fields at all is a refusal: the tool errors rather than invent a flatten.
Nothing is uploaded. pdf-lib loads the bytes in the browser, lists the form, flattens, and offers the file back. Network off, it still runs. The rest of the free tools shelf is the same class of work.
Merge PDF copies pages intact, but form field data may not survive a merge. If values matter, flatten each file first, then concatenate.
XFA LiveCycle packets will not lock
XFA stores the form in an XML packet — the InfoPath-era overlay, usually from Adobe LiveCycle. That packet is not an AcroForm dictionary. pdf-lib cannot draw it into the page. If hasXFA() is true, the tool warns you: flattening AcroForm fields will not lock XFA. If the boxes stay editable after you flatten, the file is almost always XFA.
The code still calls deleteXFA() before flatten(). That drops the packet from the file; it does not typeset the XFA widgets as page content. Empty AcroForm field lists on an XFA file are the usual tell. The error is explicit: print to PDF from Acrobat if you have to lock one of those.
Do not:
- Re-run flatten hoping the XML will become glyphs.
- Prompt an image or video model to "lock this LiveCycle form."
- Treat a screenshot of the XFA as a flatten.
A generate of a form is a picture of a document. It does not bake appearances. Re-save as a static PDF from Acrobat, or print to PDF, when the source is LiveCycle. Hybrid files exist: the widgets pdf-lib can see will bake; the XFA overlay will not. Proof the download. If you can still type, you are still in XFA.
Redaction is the opposite job
PDF Redaction rasterises the page, burns boxes into a bitmap, and writes only that image. The glyphs do not survive. Copy-out fails because the letters are not in the file. Flattening is how you keep the letters and stop the widgets. Redaction is how you destroy the letters.
Pick the object: filled values stay readable and searchable, but nobody should edit the boxes → flatten. A name or clause must not be recoverable → redact. A black rectangle sitting on live text is neither job. The glyphs remain under the box. Flattening will not hide them.
Do not flatten hoping a field disappears. Flattening preserves the filled appearance as page text. If that appearance is a number you no longer want in the file, draw the boxes on /free-tools/pdf-redact. Rebuild.
Flatten is a file pass, not a saved workflow
A saved workflow is a reusable video recipe — scene order, prompts, asset map, house style, the video model — stored so you can run it again with a fresh plot. That object has nothing to do with AcroForm widgets. Do not save a "flatten this PDF" chat as a workflow. Re-drop the current PDF. Re-read the field list. Flatten that file.
Filled AcroForm, values uneditable → flatten here. No answers yet → fill them, then flatten. Boxes still live after flatten → XFA; print to PDF from Acrobat. Letters must go → redact. A new page or a clip of a form → a generate, quoted in credits. Glyphs stay. XFA does not lock.
FAQ
Why are the boxes still editable after I flatten?
Almost always because the file is XFA, not AcroForm. Adobe-era LiveCycle files are the usual source. pdf-lib cannot draw that XML into the page. Print to PDF from Acrobat if you have to lock one of those.
Is flattening the same as printing to PDF?
No. Printing rasterises everything — text becomes pixels. Flattening keeps text as text and only bakes the field appearances into the page stream. The file stays searchable; it just stops being a form.
Should I redact instead if I need the values gone?
Yes. Flattening keeps the filled appearance as selectable page content. PDF Redaction burns boxes into a raster so the glyphs do not survive. Pick flatten to lock widgets. Pick redact to destroy letters.
Is this a reusable recipe I save and re-run?
No. A saved workflow is a video scene graph. Flatten is a local pass on the PDF you drop today. Re-run the tool on the current file; do not clone a recipe hoping it regenerates a locked form.