Class SvgCssUtils

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

public final class SvgCssUtils extends Object
Utility class that facilitates parsing values from CSS.
  • Method Details

    • splitValueList

      public static List<String> splitValueList (String value)
      Splits a given String into a list of substrings. The string is split up by commas and whitespace characters (\t, \n, \r, \f).
      Parameters:
      value - the string to be split
      Returns:
      a list containing the split strings, an empty list if the value is null or empty
    • convertFloatToString

      @Deprecated public static String convertFloatToString (float value)
      Deprecated.
      can be replaced by Float.toString(float)
      Converts a float to a String.
      Parameters:
      value - to be converted float value
      Returns:
      the value in a String representation
    • convertDoubleToString

      @Deprecated public static String convertDoubleToString (double value)
      Deprecated.
      can be replaced by Double.toString(float)
      Converts a double to a String.
      Parameters:
      value - to be converted double value
      Returns:
      the value in a String representation
    • parseAbsoluteLength

      public static float parseAbsoluteLength (AbstractSvgNodeRenderer svgNodeRenderer, String length, float percentBaseValue, float defaultValue, SvgDrawContext context)
      Parse length attribute and convert it to an absolute value.
      Parameters:
      svgNodeRenderer - renderer for which length should be parsed
      length - String for parsing
      percentBaseValue - the value on which percent length is based on
      defaultValue - default value if length is not recognized
      context - current SvgDrawContext
      Returns:
      absolute value in points
    • parseAbsoluteVerticalLength

      public static float parseAbsoluteVerticalLength (AbstractSvgNodeRenderer svgNodeRenderer, String length, float defaultValue, SvgDrawContext context)
      Parses vertical length attribute and converts it to an absolute value.
      Parameters:
      svgNodeRenderer - renderer for which length should be parsed
      length - String for parsing
      defaultValue - default value if length is not recognized
      context - current SvgDrawContext
      Returns:
      absolute value in points
    • parseAbsoluteHorizontalLength

      public static float parseAbsoluteHorizontalLength (AbstractSvgNodeRenderer svgNodeRenderer, String length, float defaultValue, SvgDrawContext context)
      Parses horizontal length attribute and converts it to an absolute value.
      Parameters:
      svgNodeRenderer - renderer for which length should be parsed
      length - String for parsing
      defaultValue - default value if length is not recognized
      context - current SvgDrawContext
      Returns:
      absolute value in points
    • parseViewBox

      public static float[] parseViewBox (ISvgNodeRenderer svgRenderer)
      Extract svg viewbox values.
      Parameters:
      svgRenderer - the ISvgNodeRenderer instance that contains the renderer tree
      Returns:
      float[4] or null, if no correct viewbox property is present.
    • extractWidthAndHeight

      public static Rectangle extractWidthAndHeight (ISvgNodeRenderer svgRenderer, float em, SvgDrawContext context)
      Extract width and height of the passed SVGNodeRenderer, defaulting to SvgDrawContext.getCustomViewport() if either one is not present. If SvgDrawContext.getCustomViewport() isn't specified, than respective viewbox values or browser default (if viewbox is missing) will be used.
      Parameters:
      svgRenderer - the ISvgNodeRenderer instance that contains the renderer tree
      em - em value in pt
      context - the svg draw context
      Returns:
      rectangle, where x,y = 0 and width and height are extracted ones by this method.