pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tolen Miller <tolenmil...@msn.com>
Subject Hybrid XFA (Livecycle) PDF - setting values of text fields in XFA
Date Sun, 11 Oct 2015 22:46:40 GMT
I'm using version 1.8.10 and had some great help in a previous thread
(subject: Cannot load pre existing PDF to access fields). I have been able
to successfully load a pre existing fill-able PDF (created in LiveCycle);
get a map of text fields from the getFieldNameList() method; then use a
comparison of the field name on the pdf and name of the database field to
map values onto the pdf.

In the end of that thread, I mentioned my own trouble with also filling the
XFA portion of the form. In the end, I opted to rip out the XFA (acroForm.
setXFA(null);) in order to get the filled static PDF to display in Adobe's
products. I have been working on another project in the past few weeks, but
am again looking at filling the XFA. After looking at the PDXFA, I am
having trouble getting a similar map or list of text field names from the
XFA. This was my first attempt, but I'm not getting what I was expecting:

System.out.println("Setting up XFA");
PDXFA xfa = acroForm.getXFA();
Document xmlDoc = xfa.getDocument();
NodeList dataElements = xmlDoc.getElementsByTagName("xfa:data");
HashMap<String, Integer> xmlFields = new HashMap<String, Integer>();
if (dataElements != null) {
for (int i = 0; i < dataElements.getLength(); i++) {
xmlFields.put(dataElements.item(0).getNodeName(), i);

My hope, after that code snippet, was to match on the String of the
xmlFields map with a field name from my db, then use the int as the
position of the dataElements list to set the text value (which would show
as the filled value in the pdf).  Where have I gone wrong?

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message