XfaForm { public String findFieldName(String name) { if (acroFieldsSom == null && xfaPresent && datasetsSom != null ) { acroFieldsSom = new AcroFieldsSearch(datasetsSom.getName2Node().keySet()); } if (acroFieldsSom != null && xfaPresent) { return acroFieldsSom.getAcroShort2LongName().containsKey(name) ? acroFieldsSom.getAcroShort2LongName().get(name) : acroFieldsSom.inverseSearchGlobal(Xml2Som.splitParts(name)); } return null; } XfaForm();  XfaForm(InputStream inputStream);  XfaForm(Document domDocument);  XfaForm(PdfDictionary acroFormDictionary);  XfaForm(PdfDocument pdfDocument); static void setXfaForm(XfaForm form, PdfDocument pdfDocument); static void setXfaForm(XfaForm form, PdfAcroForm acroForm); static Map<String, Node> extractXFANodes(Document domDocument); void write(PdfDocument document); void write(PdfAcroForm acroForm); void setXfaFieldValue(String name, String value); String getXfaFieldValue(String name); boolean isXfaPresent(); String findFieldName(String name); String findDatasetsName(String name); Node findDatasetsNode(String name); static String getNodeText(Node n); void setNodeText(Node n, String text); Document getDomDocument(); void setDomDocument(org.w3c.dom.Document domDocument); Node getDatasetsNode(); void fillXfaForm(File file); void fillXfaForm(File file, boolean readOnly); void fillXfaForm(InputStream is); void fillXfaForm(InputStream is, boolean readOnly); void fillXfaForm(InputSource is); void fillXfaForm(InputSource is, boolean readOnly); void fillXfaForm(Node node); void fillXfaForm(Node node, boolean readOnly); static final String XFA_DATA_SCHEMA; }
@Test public void findFieldName() throws IOException { String inFileName = sourceFolder + "TextField1.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFileName)); PdfAcroForm acroForm = PdfAcroForm.getAcroForm(pdfDocument, true); XfaForm xfaForm = acroForm.getXfaForm(); xfaForm.findFieldName("TextField1"); String secondRun = xfaForm.findFieldName("TextField1"); Assert.assertNotNull(secondRun); }
@Test public void findFieldNameWithoutDataSet() throws IOException { String inFileName = sourceFolder + "TextField1_empty.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFileName)); PdfAcroForm acroForm = PdfAcroForm.getAcroForm(pdfDocument, true); XfaForm xfaForm = acroForm.getXfaForm(); String name = xfaForm.findFieldName("TextField1"); Assert.assertNull(name); }