I am trying to fill XFA pdf forms using python, however I don’t see any library that can perform this.
I have used fillpdf to update the forms but that does not work.
Below is my code:
import fillpdf
from fillpdf import fillpdfs
fillpdfs.get_form_fields('f1040.pdf', sort=False, page_number=1)
Data_dict= {*updated form fields*}
fillpdfs.write_fillable_pdf('f1040.pdf', 'output.pdf', data_dict, flatten=False)
Any suggestion about alternative libraries?
From the Adobe API support partners (Datalogics)
The Fix: How to Edit XFA Forms
Most form fillers will use PDFtk as its one command line to export and we can export the FDF data direct. to allow bulk editing of say one file per person.
pdftk f1040-fred.pdf generate_fdf output f1040-fred.fdf verboseBut here is the Problem The Edited FDF can open the PDF but cannot repopulate the static fields as its not flattened. Thus there is a lack of tools to work with Adobe licensed proprietary XFA content. You need Adobe Acrobat to be sure of XFA working across the board.
Hence the comments from Adobe Support Partner simplify the XFA into a standard AcroForm (which should work with PDFtk and other [x]FDF applications)
Note that many libraries that can work with PDF will have problems with XFA as it is only the coverpage (Adobe advert to use Acrobat) that is a true PDF object.
Aspose have libraries that can convert XFA.xmp into AcroForm.PDF, here we see the dynamic version in top and the workable AcroForm in lower picture after conversion by Aspose
Finally we can work with standard FDF in the now regular.pdf
Here is the difference Before and After in a PDF viewer
Later Edit interesting that currently Edge is now using Adobe Plug-in but that XFA form is still NOT usable ?
However Acrobat official statement is
So I presume that means the full Adobe plug-in. https://helpx.adobe.com/livecycle/kb/xfa-forms-firefox-chrome.html