I have a pdf file which has several form fields which can be filled with values, like text fields, radio box etc.
I am trying to manipulate the fields programmatically by reading the pdf. I have tried libraries like PDFBox, iTextPdf etc. But every time I see fields list returned empty. My basic code is:
val template = new File(....)
val doc = PDDocument.load(template)
val docCatalog = doc.getDocumentCatalog
val acroForm = docCatalog.getAcroForm
println("Fields:"+ acroForm.getFields)
Fields list is coming out to be empty, even though file does have fields.
What am I missing here?
As it turned out, the input pdf file I was using is actually a XFA based file and not acroform, and most of the libraries don't support XFA.
So we need to convert the file to acroform.
Another approach can be to use aspose . It provides API to populate XFA forms too.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.