Package com.itextpdf.svg.utils
Class SvgCssUtils
java.lang.Object
com.itextpdf.svg.utils.SvgCssUtils
Utility class that facilitates parsing values from CSS.
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
convertDoubleToString
(double value) Deprecated.static String
convertFloatToString
(float value) Deprecated.can be replaced byFloat.toString(float)
static Rectangle
extractWidthAndHeight
(ISvgNodeRenderer svgRenderer, float em, SvgDrawContext context) Extract width and height of the passed SVGNodeRenderer, defaulting toSvgDrawContext.getCustomViewport()
if either one is not present.static float
parseAbsoluteHorizontalLength
(AbstractSvgNodeRenderer svgNodeRenderer, String length, float defaultValue, SvgDrawContext context) Parses horizontal length attribute and converts it to an absolute value.static float
parseAbsoluteLength
(AbstractSvgNodeRenderer svgNodeRenderer, String length, float percentBaseValue, float defaultValue, SvgDrawContext context) Parse length attribute and convert it to an absolute value.static float
parseAbsoluteVerticalLength
(AbstractSvgNodeRenderer svgNodeRenderer, String length, float defaultValue, SvgDrawContext context) Parses vertical length attribute and converts it to an absolute value.static float[]
parseViewBox
(ISvgNodeRenderer svgRenderer) Extract svg viewbox values.splitValueList
(String value) Splits a given String into a list of substrings.
-
Method Details
-
splitValueList
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.can be replaced byFloat.toString(float)
Converts a float to a String.- Parameters:
-
value
- to be converted float value - Returns:
- the value in a String representation
-
convertDoubleToString
Deprecated.can be replaced byDouble.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
- currentSvgDrawContext
- 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
- currentSvgDrawContext
- 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
- currentSvgDrawContext
- Returns:
- absolute value in points
-
parseViewBox
Extract svg viewbox values.- Parameters:
-
svgRenderer
- theISvgNodeRenderer
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 toSvgDrawContext.getCustomViewport()
if either one is not present. IfSvgDrawContext.getCustomViewport()
isn't specified, than respective viewbox values or browser default (if viewbox is missing) will be used.- Parameters:
-
svgRenderer
- theISvgNodeRenderer
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.
-
Double.toString(float)