/// <summary>Process the text contained in the text-node</summary>
 /// <param name="textNode">node containing text to process</param>
 private void ProcessText(ITextNode textNode)
 {
     ISvgNodeRenderer parentRenderer = this.processorState.Top();
     if (parentRenderer is TextSvgBranchRenderer) {
         String wholeText = textNode.WholeText();
         if (!"".Equals(wholeText) && !SvgTextUtil.IsOnlyWhiteSpace(wholeText)) {
             TextLeafSvgNodeRenderer textLeaf = new TextLeafSvgNodeRenderer();
             textLeaf.SetParent(parentRenderer);
             textLeaf.SetAttribute(SvgConstants.Attributes.TEXT_CONTENT, wholeText);
             ((TextSvgBranchRenderer)parentRenderer).AddChild(textLeaf);
         }
     }
 }
Пример #2
0
        /// <summary>Process the text contained in the text-node</summary>
        /// <param name="textNode">node containing text to process</param>
        private void ProcessText(ITextNode textNode)
        {
            ISvgNodeRenderer parentRenderer = this.processorState.Top();

            if (parentRenderer is TextSvgNodeRenderer)
            {
                // when svg is parsed by jsoup it leaves all whitespace in text element as is. Meaning that
                // tab/space indented xml files will retain their tabs and spaces.
                // The following regex replaces all whitespace with a single space.
                //TODO(RND-906) evaluate regex and trim methods
                String trimmedText = iText.IO.Util.StringUtil.ReplaceAll(textNode.WholeText(), "\\s+", " ");
                //Trim leading whitespace
                trimmedText = SvgTextUtil.TrimLeadingWhitespace(trimmedText);
                //Trim trailing whitespace
                trimmedText = SvgTextUtil.TrimTrailingWhitespace(trimmedText);
                parentRenderer.SetAttribute(SvgConstants.Attributes.TEXT_CONTENT, trimmedText);
            }
        }