Mandroid
Mandroid

Reputation: 7524

PDFBox, iTextPdfPDF: pdf form returning no fields

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?

Upvotes: 0

Views: 166

Answers (1)

Mandroid
Mandroid

Reputation: 7524

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.

Upvotes: 0

Related Questions