Package com.itextpdf.tool.xml.css
Class StyleAttrCSSResolver
java.lang.Object
com.itextpdf.tool.xml.css.StyleAttrCSSResolver
- All Implemented Interfaces:
CSSResolver
Resolves CSS properties.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CssFilesprivate CssInheritanceRulesprivate FileRetrievestatic final Stringprivate final CssUtils -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a newStyleAttrCSSResolverwith default settings.StyleAttrCSSResolver(CssFiles cssFiles) Construct a new StyleAttrCSSResolver with the givenCssFilesand theDefaultCssInheritanceRules.StyleAttrCSSResolver(CssFiles cssFiles, CssUtils utils) Construct a new StyleAttrCSSResolver with the givenCssFilesandCssUtilsand theDefaultCssInheritanceRules.StyleAttrCSSResolver(CssFiles cssFiles, FileRetrieve r) StyleAttrCSSResolver(CssInheritanceRules rules, CssFiles cssFiles, CssUtils utils) StyleAttrCSSResolver(CssInheritanceRules rules, CssFiles cssFiles, CssUtils utils, FileRetrieve fileRetrieve) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a file to the CssFiles Collection.voidAdd a piece of CSS code.voidAdd a piece of CSS code.voidaddCssFile(String href, boolean isPersistent) Add a file to the CssFiles Collection.private booleancanInherite(Tag t, String property) Defaults to true if noCssInheritanceRulesimplementation set.clear()private StringmergeTextDecorationRules(String oldRule, String newRule) private booleanmustInherit(String tag) Defaults to true if noCssInheritanceRulesimplementation set.voidresolveStyles(Tag t) Also taking into account the CSS properties of any parent tag in the given tag.voidsetCssInheritance(CssInheritanceRules cssInheritanceRules) By setting an implementation ofCssInheritanceRulesa developer can set rules on what css selectors are inherited from parent tags.voidvoidsetFileRetrieve(FileRetrieve retrieve) TheFileRetrieveimplementation to use inaddCss(String, boolean).private void
-
Field Details
-
STYLE
- See Also:
-
utils
-
inherit
-
cssFiles
-
retrieve
-
-
Constructor Details
-
StyleAttrCSSResolver
public StyleAttrCSSResolver()Construct a newStyleAttrCSSResolverwith default settings. -
StyleAttrCSSResolver
Construct a new StyleAttrCSSResolver with the givenCssFilesand theDefaultCssInheritanceRules.- Parameters:
cssFiles- aCssFilesimplementation.
-
StyleAttrCSSResolver
Construct a new StyleAttrCSSResolver with the givenCssFilesandCssUtilsand theDefaultCssInheritanceRules.- Parameters:
cssFiles- aCssFilesimplementation.utils- the CssUtils to use.
-
StyleAttrCSSResolver
- Parameters:
rules- theCssInheritanceRulesto use.cssFiles- aCssFilesimplementation.utils- the CssUtils to use.
-
StyleAttrCSSResolver
public StyleAttrCSSResolver(CssInheritanceRules rules, CssFiles cssFiles, CssUtils utils, FileRetrieve fileRetrieve) - Parameters:
rules- theCssInheritanceRulesto use.cssFiles- aCssFilesimplementation.utils- the CssUtils to use.fileRetrieve- theFileRetrieveimplementation
-
StyleAttrCSSResolver
- Parameters:
cssFiles- theCssFileimplementationr- theFileRetrieveimplementation
-
-
Method Details
-
resolveStyles
Also taking into account the CSS properties of any parent tag in the given tag.- Specified by:
resolveStylesin interfaceCSSResolver- Parameters:
t- the tag.- See Also:
-
mergeTextDecorationRules
-
splitRules
- Parameters:
css- the css map to populatekey- the propertyvalue- the value
-
setCssInheritance
By setting an implementation ofCssInheritanceRulesa developer can set rules on what css selectors are inherited from parent tags.- Parameters:
cssInheritanceRules- the inherit to set
-
canInherite
Defaults to true if noCssInheritanceRulesimplementation set.- Parameters:
t-property-- Returns:
- true if may be inherited false otherwise
-
mustInherit
Defaults to true if noCssInheritanceRulesimplementation set.- Parameters:
tag-- Returns:
- true if must be inherited false otherwise
-
addCss
public void addCss(String content, String charSet, boolean isPersistent) throws CssResolverException Description copied from interface:CSSResolverAdd a piece of CSS code.- Specified by:
addCssin interfaceCSSResolver- Parameters:
content- the CSScharSet- a charsetisPersistent- true if the added css should not be deleted on a call to clear- Throws:
CssResolverException- thrown if something goes wrong
-
addCssFile
Add a file to the CssFiles Collection.- Specified by:
addCssFilein interfaceCSSResolver- Parameters:
href- the path, if it starts with http we try to retrieve the file from the net, if not we try a normal file operation.isPersistent- true if the added css should not be deleted on a call to clear- Throws:
CssResolverException- thrown if something goes wrong
-
addCss
Add a file to the CssFiles Collection.- Specified by:
addCssin interfaceCSSResolver- Parameters:
file- the CssFile to add.
-
addCss
Description copied from interface:CSSResolverAdd a piece of CSS code.- Specified by:
addCssin interfaceCSSResolver- Parameters:
content- the content to parse to cssisPersistent- true if the added css should not be deleted on a call to clear- Throws:
CssResolverException- thrown if something goes wrong
-
setCssInheritanceRules
- Parameters:
inherit- the inherit to set
-
setFileRetrieve
TheFileRetrieveimplementation to use inaddCss(String, boolean).- Specified by:
setFileRetrievein interfaceCSSResolver- Parameters:
retrieve- the retrieve to set
-
clear
- Specified by:
clearin interfaceCSSResolver- Returns:
- an instance of this resolver
- Throws:
CssResolverException- thrown if something goes wrong
-