I'm trying to parse CSS text containing a @Page rule, but it is raising a runtime error and ignoring it completely.
The following piece of code ilustrates what I'm trying to do:
public class Main {
public static void main(String arg[]) throws IOException {
String str = "@page rotated { size : landscape }";
InputSource source = new InputSource(new StringReader(str));
CSSOMParser parser = new CSSOMParser(new SACParserCSS3());
CSSStyleSheet sheet = parser.parseStyleSheet(source, null, null);
CSSRuleList rules = sheet.getCssRules();
for (int index = 0; index < rules.getLength(); ++index) {
CSSRule rule = rules.item(index);
System.out.println(rule.getCssText());
}
}
}
Console Output:
null [1:7] Error in @page rule. (Invalid token "rotated". Was expecting one of: <S>, <LBRACE>, ":".)
null [1:7] Ignoring the whole rule.
Note: I suppressed import package declarations to make it shorter.
According to W3C CSS validator the style "@page rotated { size : landscape }
" is fine.
See also: https://www.w3.org/TR/REC-CSS2/page.html (section 13.3.2)
Anonymous
Diff:
Named page layouts are not supported at the moment (only pseudo pages are supported).
Will try to add the support
Diff:
Have added initial support for page selectors. Please check if this is sufficient for you.