Class SvgTextUtil

java.lang.Object
com.itextpdf.svg.utils.SvgTextUtil

public final class SvgTextUtil extends Object
Class containing utility methods for text operations in the context of SVG processing
  • Method Details

    • trimLeadingWhitespace

      public static String trimLeadingWhitespace (String toTrim)
      Trim all the leading whitespace characters from the passed string
      Parameters:
      toTrim - string to trim
      Returns:
      string with all leading whitespace characters removed
    • trimTrailingWhitespace

      public static String trimTrailingWhitespace (String toTrim)
      Trim all the trailing whitespace characters from the passed string
      Parameters:
      toTrim - string to trim
      Returns:
      string with al trailing whitespace characters removed
    • processWhiteSpace

      public static void processWhiteSpace (TextSvgBranchRenderer root, boolean isLeadingElement)
      Process the whitespace inside the Text Tree. Whitespace is collapsed and new lines are handled A leading element in each subtree is handled different: the preceding whitespace is trimmed instead of kept
      Parameters:
      root - root of the text-renderer subtree
      isLeadingElement - true if this element is a leading element(either the first child or the first element after an absolute position change)
    • isOnlyWhiteSpace

      public static boolean isOnlyWhiteSpace (String s)
      Check if the String is only composed of whitespace characters
      Parameters:
      s - string to check
      Returns:
      true if the string only contains whitespace characters, false otherwise
    • resolveFontSize

      public static float resolveFontSize (ISvgTextNodeRenderer renderer, float parentFontSize)
      Resolve the font size stored inside the passed renderer
      Parameters:
      renderer - renderer containing the font size declaration
      parentFontSize - parent font size to fall back on if the renderer does not contain a font size declarations or if the stored declaration is invalid
      Returns:
      float containing the font-size, or the parent font size if the renderer's declaration cannot be resolved
    • filterReferenceValue

      public static String filterReferenceValue (String name)
      The reference value may contain a hashtag character or 'url' designation and this method will filter them.
      Parameters:
      name - value to be filtered
      Returns:
      filtered value