Exemplo n.º 1
0
        /**
         * Extracts the nodes from the domDocument.
         * @since    2.1.5
         */
        private void ExtractNodes()
        {
            XmlNode n = domDocument.FirstChild;

            while (n.NodeType != XmlNodeType.Element || n.ChildNodes.Count == 0)
            {
                n = n.NextSibling;
            }
            n = n.FirstChild;
            while (n != null)
            {
                if (n.NodeType == XmlNodeType.Element)
                {
                    String s = n.LocalName;
                    if ("template".Equals(s))
                    {
                        templateNode = n;
                        templateSom  = new Xml2SomTemplate(n);
                    }
                    else if ("datasets".Equals(s))
                    {
                        datasetsNode = n;
                        datasetsSom  = new Xml2SomDatasets(n.FirstChild);
                    }
                }
                n = n.NextSibling;
            }
        }
Exemplo n.º 2
0
        /**
         * Extracts the nodes from the domDocument.
         * @since    2.1.5
         */
        private void ExtractNodes()
        {
            Dictionary <String, XmlNode> xfaNodes = ExtractXFANodes(domDocument);

            if (xfaNodes.ContainsKey("template"))
            {
                templateNode = xfaNodes["template"];
                templateSom  = new Xml2SomTemplate(templateNode);
            }
            if (xfaNodes.ContainsKey("datasets"))
            {
                datasetsNode = xfaNodes["datasets"];
                datasetsSom  = new Xml2SomDatasets(datasetsNode.FirstChild);
            }

            if (datasetsNode == null)
            {
                CreateDatasetsNode(domDocument.FirstChild);
            }
        }
Exemplo n.º 3
0
 /**
 * A constructor from a <CODE>PdfReader</CODE>. It basically does everything
 * from finding the XFA stream to the XML parsing.
 * @param reader the reader
 * @throws java.io.IOException on error
 * @throws javax.xml.parsers.ParserConfigurationException on error
 * @throws org.xml.sax.SAXException on error
 */
 public XfaForm(PdfReader reader)
 {
     this.reader = reader;
     PdfDictionary af = (PdfDictionary)PdfReader.GetPdfObjectRelease(reader.Catalog.Get(PdfName.ACROFORM));
     if (af == null) {
         xfaPresent = false;
         return;
     }
     PdfObject xfa = PdfReader.GetPdfObjectRelease(af.Get(PdfName.XFA));
     if (xfa == null) {
         xfaPresent = false;
         return;
     }
     xfaPresent = true;
     MemoryStream bout = new MemoryStream();
     if (xfa.IsArray()) {
         ArrayList ar = ((PdfArray)xfa).ArrayList;
         for (int k = 1; k < ar.Count; k += 2) {
             PdfObject ob = PdfReader.GetPdfObject((PdfObject)ar[k]);
             if (ob is PRStream) {
                 byte[] b = PdfReader.GetStreamBytes((PRStream)ob);
                 bout.Write(b, 0, b.Length);
             }
         }
     }
     else if (xfa is PRStream) {
         byte[] b = PdfReader.GetStreamBytes((PRStream)xfa);
         bout.Write(b, 0, b.Length);
     }
     bout.Seek(0, SeekOrigin.Begin);
     XmlTextReader xtr = new XmlTextReader(bout);
     domDocument = new XmlDocument();
     domDocument.Load(xtr);
     XmlNode n = domDocument.FirstChild;
     while (n.NodeType != XmlNodeType.Element)
         n = n.NextSibling;
     n = n.FirstChild;
     while (n != null) {
         if (n.NodeType == XmlNodeType.Element) {
             String s = n.LocalName;
             if (s.Equals("template")) {
                 templateNode = n;
                 templateSom = new Xml2SomTemplate(n);
             }
             else if (s.Equals("datasets")) {
                 datasetsNode = n;
                 datasetsSom = new Xml2SomDatasets(n.FirstChild);
             }
         }
         n = n.NextSibling;
     }
 }
Exemplo n.º 4
0
 /**
 * Extracts the nodes from the domDocument.
 * @since    2.1.5
 */
 private void ExtractNodes()
 {
     XmlNode n = domDocument.FirstChild;
     while (n.NodeType != XmlNodeType.Element || n.ChildNodes.Count == 0)
         n = n.NextSibling;
     n = n.FirstChild;
     while (n != null) {
         if (n.NodeType == XmlNodeType.Element) {
             String s = n.LocalName;
             if (s.Equals("template")) {
                 templateNode = n;
                 templateSom = new Xml2SomTemplate(n);
             }
             else if (s.Equals("datasets")) {
                 datasetsNode = n;
                 datasetsSom = new Xml2SomDatasets(n.FirstChild);
             }
         }
         n = n.NextSibling;
     }
 }
Exemplo n.º 5
0
        /**
         * A constructor from a <CODE>PdfReader</CODE>. It basically does everything
         * from finding the XFA stream to the XML parsing.
         * @param reader the reader
         * @throws java.io.IOException on error
         * @throws javax.xml.parsers.ParserConfigurationException on error
         * @throws org.xml.sax.SAXException on error
         */
        public XfaForm(PdfReader reader)
        {
            this.reader = reader;
            PdfDictionary af = (PdfDictionary)PdfReader.GetPdfObjectRelease(reader.Catalog.Get(PdfName.ACROFORM));

            if (af == null)
            {
                xfaPresent = false;
                return;
            }
            PdfObject xfa = PdfReader.GetPdfObjectRelease(af.Get(PdfName.XFA));

            if (xfa == null)
            {
                xfaPresent = false;
                return;
            }
            xfaPresent = true;
            MemoryStream bout = new MemoryStream();

            if (xfa.IsArray())
            {
                ArrayList ar = ((PdfArray)xfa).ArrayList;
                for (int k = 1; k < ar.Count; k += 2)
                {
                    PdfObject ob = PdfReader.GetPdfObject((PdfObject)ar[k]);
                    if (ob != null && ob is PRStream)
                    {
                        byte[] b = PdfReader.GetStreamBytes((PRStream)ob);
                        bout.Write(b, 0, b.Length);
                    }
                }
            }
            else if (xfa is PRStream)
            {
                byte[] b = PdfReader.GetStreamBytes((PRStream)xfa);
                bout.Write(b, 0, b.Length);
            }
            bout.Seek(0, SeekOrigin.Begin);
            XmlTextReader xtr = new XmlTextReader(bout);

            domDocument = new XmlDocument();
            domDocument.Load(xtr);
            XmlNode n = domDocument.FirstChild;

            while (n.NodeType != XmlNodeType.Element)
            {
                n = n.NextSibling;
            }
            n = n.FirstChild;
            while (n != null)
            {
                if (n.NodeType == XmlNodeType.Element)
                {
                    String s = n.LocalName;
                    if (s.Equals("template"))
                    {
                        templateNode = n;
                        templateSom  = new Xml2SomTemplate(n);
                    }
                    else if (s.Equals("datasets"))
                    {
                        datasetsNode = n;
                        datasetsSom  = new Xml2SomDatasets(n.FirstChild);
                    }
                }
                n = n.NextSibling;
            }
        }