Class XfaForm

java.lang.Object
com.lowagie.text.pdf.XfaForm

public class XfaForm extends Object
Processes XFA forms.
  • Field Details

  • Constructor Details

  • Method Details

    • getXfaObject

      public static PdfObject getXfaObject(PdfReader reader)
      Return the XFA Object, could be an array, could be a Stream. Returns null f no XFA Object is present.
      Parameters:
      reader - a PdfReader instance
      Returns:
      the XFA object
      Since:
      2.1.3
    • setXfa

      public static void setXfa(XfaForm form, PdfReader reader, PdfWriter writer) throws IOException
      Sets the XFA key from a byte array. The old XFA is erased.
      Parameters:
      form - the data
      reader - the reader
      writer - the writer
      Throws:
      IOException - on error
    • serializeDoc

      public static byte[] serializeDoc(Node n) throws IOException
      Serializes a XML document to a byte array.
      Parameters:
      n - the XML document
      Returns:
      the serialized XML document
      Throws:
      IOException - on error
    • getNodeText

      public static String getNodeText(Node n)
      Gets all the text contained in the child nodes of this node.
      Parameters:
      n - the Node
      Returns:
      the text found or "" if no text was found
    • getNodeText

      private static String getNodeText(Node n, String name)
    • extractNodes

      private void extractNodes()
      Extracts the nodes from the domDocument.
      Since:
      2.1.5
    • setXfa

      public void setXfa(PdfWriter writer) throws IOException
      Sets the XFA key from the instance data. The old XFA is erased.
      Parameters:
      writer - the writer
      Throws:
      IOException - on error
    • isXfaPresent

      public boolean isXfaPresent()
      Returns true if it is a XFA form.
      Returns:
      true if it is a XFA form
    • setXfaPresent

      public void setXfaPresent(boolean xfaPresent)
      Sets the XFA form flag signaling that this is a valid XFA form.
      Parameters:
      xfaPresent - the XFA form flag signaling that this is a valid XFA form
    • getDomDocument

      public Document getDomDocument()
      Gets the top level DOM document.
      Returns:
      the top level DOM document
    • setDomDocument

      public void setDomDocument(Document domDocument)
      Sets the top DOM document.
      Parameters:
      domDocument - the top DOM document
    • findFieldName

      public String findFieldName(String name, AcroFields af)
      Finds the complete field name contained in the "classic" forms from a partial name.
      Parameters:
      name - the complete or partial name
      af - the fields
      Returns:
      the complete name or null if not found
    • findDatasetsName

      public String findDatasetsName(String name)
      Finds the complete SOM name contained in the datasets section from a possibly partial name.
      Parameters:
      name - the complete or partial name
      Returns:
      the complete name or null if not found
    • findDatasetsNode

      public Node findDatasetsNode(String name)
      Finds the Node contained in the datasets section from a possibly partial name.
      Parameters:
      name - the complete or partial name
      Returns:
      the Node or null if not found
    • setNodeText

      public void setNodeText(Node n, String text)
      Sets the text of this node. All the child's node are deleted and a new child text node is created.
      Parameters:
      n - the Node to add the text to
      text - the text to add
    • getReader

      public PdfReader getReader()
      Gets the PdfReader used by this instance.
      Returns:
      the PdfReader used by this instance
    • setReader

      public void setReader(PdfReader reader)
      Sets the PdfReader to be used by this instance.
      Parameters:
      reader - the PdfReader to be used by this instance
    • isChanged

      public boolean isChanged()
      Checks if this XFA form was changed.
      Returns:
      true if this XFA form was changed
    • setChanged

      public void setChanged(boolean changed)
      Sets the changed status of this XFA instance.
      Parameters:
      changed - the changed status of this XFA instance
    • getTemplateSom

      public XfaForm.Xml2SomTemplate getTemplateSom()
      Gets the class that contains the template processing section of the XFA.
      Returns:
      the class that contains the template processing section of the XFA
    • setTemplateSom

      public void setTemplateSom(XfaForm.Xml2SomTemplate templateSom)
      Sets the class that contains the template processing section of the XFA
      Parameters:
      templateSom - the class that contains the template processing section of the XFA
    • getDatasetsSom

      public XfaForm.Xml2SomDatasets getDatasetsSom()
      Gets the class that contains the datasets processing section of the XFA.
      Returns:
      the class that contains the datasets processing section of the XFA
    • setDatasetsSom

      public void setDatasetsSom(XfaForm.Xml2SomDatasets datasetsSom)
      Sets the class that contains the datasets processing section of the XFA.
      Parameters:
      datasetsSom - the class that contains the datasets processing section of the XFA
    • getAcroFieldsSom

      public XfaForm.AcroFieldsSearch getAcroFieldsSom()
      Gets the class that contains the "classic" fields processing.
      Returns:
      the class that contains the "classic" fields processing
    • setAcroFieldsSom

      public void setAcroFieldsSom(XfaForm.AcroFieldsSearch acroFieldsSom)
      Sets the class that contains the "classic" fields processing.
      Parameters:
      acroFieldsSom - the class that contains the "classic" fields processing
    • getDatasetsNode

      public Node getDatasetsNode()
      Gets the Node that corresponds to the datasets part.
      Returns:
      the Node that corresponds to the datasets part
    • fillXfaForm

      public void fillXfaForm(File file) throws ParserConfigurationException, SAXException, IOException
      Throws:
      ParserConfigurationException
      SAXException
      IOException
    • fillXfaForm

      public void fillXfaForm(InputStream is) throws ParserConfigurationException, SAXException, IOException
      Throws:
      ParserConfigurationException
      SAXException
      IOException
    • fillXfaForm

      public void fillXfaForm(InputSource is) throws ParserConfigurationException, SAXException, IOException
      Throws:
      ParserConfigurationException
      SAXException
      IOException
    • fillXfaForm

      public void fillXfaForm(Node node)
      Replaces the data under datasets/data.
      Parameters:
      node - node to fill data under
      Since:
      iText 5.0.0