public class CssUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
extractUrl(String url)
Parses url("file.jpg") to file.jpg .
|
static int |
findNextUnescapedChar(String source, char ch, int startIndex)
Find the next unescaped character.
|
static boolean |
isBase64Data(String data)
Checks if a data is base 64 encoded.
|
static boolean |
isColorProperty(String value)
Checks if a value is a color property.
|
static boolean |
isMetricValue(String value)
Checks whether a string contains an allowed metric unit in HTML/CSS; px, in, cm, mm, pc or pt.
|
static boolean |
isNumericValue(String value)
Checks whether a string matches a numeric value (e.g.
|
static boolean |
isRelativeValue(String value)
Checks whether a string contains an allowed value relative to previously set value.
|
static boolean |
isRemValue(String value)
Checks whether a string contains an allowed value relative to previously set root value.
|
static String |
normalizeCssProperty(String str)
Normalizes a CSS property.
|
static float |
parseAbsoluteLength(String length)
Parses the absolute length.
|
static float |
parseAbsoluteLength(String length, String defaultMetric)
Parses a length with an allowed metric unit (px, pt, in, cm, mm, pc, q) or numeric value (e.g.
|
static int[] |
parseAspectRatio(String str)
Parses an aspect ratio into an array with two integers.
|
static Float |
parseFloat(String str)
Parses a float without throwing an exception if something goes wrong.
|
static Integer |
parseInteger(String str)
Parses an integer without throwing an exception if something goes wrong.
|
static com.itextpdf.layout.property.UnitValue |
parseLengthValueToPt(String value, float emValue, float remValue)
Parses the length value to pt.
|
static float |
parseRelativeValue(String relativeValue, float baseValue)
Parses an relative value based on the base value that was given, in the metric unit of the base value.
(e.g. |
static float |
parseResolution(String resolutionStr)
Parses the resolution.
|
static float[] |
parseRgbaColor(String colorValue)
Parses the RGBA color.
|
static String |
removeDoubleSpacesAndTrim(String str)
Removes double spaces and trims a string.
|
public static String normalizeCssProperty(String str)
str
- the property
public static String removeDoubleSpacesAndTrim(String str)
str
- the string
public static Integer parseInteger(String str)
str
- a string that might be an integer value
public static Float parseFloat(String str)
str
- a string that might be a float value
public static int[] parseAspectRatio(String str)
str
- a string that might contain two integer values
public static float parseAbsoluteLength(String length, String defaultMetric)
length
- the string containing the length.
defaultMetric
- the string containing the metric if it is possible that the length string does not contain one. If null the length is considered to be in px as is default in HTML/CSS.
public static float parseAbsoluteLength(String length)
length
- the length as a string
public static float parseRelativeValue(String relativeValue, float baseValue)
relativeValue
- in %, em or ex.
baseValue
- the value the returned float is based on.
public static com.itextpdf.layout.property.UnitValue parseLengthValueToPt(String value, float emValue, float remValue)
value
- the value
emValue
- the em value
remValue
- the root em value
public static float parseResolution(String resolutionStr)
resolutionStr
- the resolution as a string
public static boolean isColorProperty(String value)
value
- the value
public static float[] parseRgbaColor(String colorValue)
colorValue
- the color value
public static boolean isMetricValue(String value)
value
- the string that needs to be checked.
public static boolean isRelativeValue(String value)
value
- the string that needs to be checked.
public static boolean isRemValue(String value)
value
- the string that needs to be checked.
public static boolean isNumericValue(String value)
value
- the string that needs to be checked.
public static String extractUrl(String url)
url("file.jpg")
to file.jpg
.
url
- the url attribute to parse
public static boolean isBase64Data(String data)
data
- the data
public static int findNextUnescapedChar(String source, char ch, int startIndex)
source
- a source
ch
- the character to look for
startIndex
- where to start looking
Copyright © 1998–2019 iText Group NV. All rights reserved.