Exemple #1
0
        // does not recurse.
        private void NormaliseTextNodes(iText.StyledXmlParser.Jsoup.Nodes.Element element)
        {
            IList <iText.StyledXmlParser.Jsoup.Nodes.Node> toMove = new List <iText.StyledXmlParser.Jsoup.Nodes.Node>();

            foreach (iText.StyledXmlParser.Jsoup.Nodes.Node node in element.childNodes)
            {
                if (node is TextNode)
                {
                    TextNode tn = (TextNode)node;
                    if (!tn.IsBlank())
                    {
                        toMove.Add(tn);
                    }
                }
            }
            for (int i = toMove.Count - 1; i >= 0; i--)
            {
                iText.StyledXmlParser.Jsoup.Nodes.Node node = toMove[i];
                element.RemoveChild(node);
                Body().PrependChild(new TextNode(" ", ""));
                Body().PrependChild(node);
            }
        }