I have a pdf. The xfa:datasets node looks like this:
<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><xfa:data xfa:dataNode="dataGroup" /></xfa:datasets>
Thus I can extract no information about the underlying schema, so I can't generate xml to fill this.
the pdf uses javascript to add rows to the tables, in the following manner:
this.resolveNode('document_table.Table3._user_input').addInstance(1);
using iTextSharp in the Xfa.TemplateSom
, I can find references to the form elements. In the DomDocument
I can search and find the various elements in the xml, but this is where I'm stuck. There seems to be no relationship to the XFA data, I tried the XFA Worker demo and the demo confirmed the pdf has no XFA data.
I'm unsure what type of form this is if it's not XFA and not AcroFields.
Bruno, I bought your book and while I haven't read it cover to cover, it doesn't cover this scenario so far as I can tell. Any insight anyone has on how this type of form can be filled, I would appreciate it.
Right now, I'm wondering if I have to append javascript which mimicks the actions and sets the data. Since there are many forms, each with a different layout, parsing through all of them manually to get the hierarchy and replicate the javascript on my own is onerous and frankly I'm not sure this approach will be successful.
The form is an XFA form, and the fact that the DataDescription
is missing is a pity, but it's not abnormal. The description of the data is optional, not mandatory.
If it's your intention to fill the form with iText, then you should forget about JavaScript to add rows. You should not confuse manual data entry —where a user enters the data row by row, adding rows manually— with automated data entry —where you provide data in the form of an XML file. If you have a table with rows, then those rows will be populated with as many rows as there are data rows in your source XML.
The real question is: How do you compose that XML if there is no data description?
Once you know the expected structure of the XML, you shouldn't have to worry about JavaScript. The JavaScript that is there to deal with user actions is irrelevant in the context of automatic form filling. The only JavaScript that matters in the context of filling an XFA form with iText, is the JavaScript that does automatic formatting of data (e.g. format a date, a currency,...).