<< back
PD4ML: Proprietary CSS features
As you know, PD4ML supports rendering/conversion of CSS-styled HTML
documents. However we never claim that PD4ML is CSS2 or CSS3 compliant. There
are some CSS features, whose implementation we decide to skip due to technical
complexities or potential performance issues; there are some features we ignored
as they are not that popular (from our perspective); some features are not
supported by our CSS parser.FYI: PD4ML utilizes a third-party library ss_css2.jar of open-source
CSS Parser project. The library "officially" supports CSS Level 2, that
makes an implementation of highly demanded popular CSS3 features complicated, or
even impossible. We patched the library to workaround some limitations, however
there is still a number of open issues. (The patched source code
of the library is available for download from our site).
By the link you can find the list of currently
supported CSS properties. As you may see the list ends with some non-standard
PD4ML-specific properties. Below we'll try to shed light on them.
But first, we start with supported CSS media types and a proprietary type 'pdf'.
1. Media type 'pdf'
By default PD4ML applies CSS properties, defined for media type 'screen'
(if a media type specified). Of course, it also applies styles of media type 'all',
but 'print' is ignored. If for some reason print styles must be applied,
PD4ML allows to enable them with the API call:
Map m = new HashMap();
m.put(PD4Constants.PD4ML_MEDIA_TYPE_PRINT, "add");
pd4ml.setDynamicParams(m);
The above code
enables 'print' media type in addition to 'screen'. If 'screen'
styles are undesired, the following disables 'screen' and enables 'print'.
Map m = new HashMap();
m.put(PD4Constants.PD4ML_MEDIA_TYPE_PRINT, "override");
pd4ml.setDynamicParams(m);
In situations, when very special styles are required for pdf conversions only, there is a proprietary media type 'pdf'.
As the type is known to PD4ML only, it will be ignored by the
regular web browsers.
@media pdf {
TR, IMG {page-break-inside: avoid;}
}
CSS media queries are not supported.
2. Proprietary CSS properties
3. Supported CSS selectors.PD4ML supports most of CSS2
selectors including some popular CSS3 constructs. Here is the list.
* | Universal selector | Matches any element | E | Type selectors | Matches any E element (i.e., an element of type E) | E.foo | Class selector | Matches E element of class "foo" | .foo (or *.foo) | Class selector | Matches any element of class "foo" | E.foo.bar | Multi-class selector | Matches E element of
both classes "foo" and "bar" | .foo.bar (or *.foo.bar) | Multi-class selector | Matches any element of
both classes "foo" and "bar" | E F | Descendant selectors | Matches any F element that is a child of an element E | E > F | Child selectors | Matches any F element that is a child of an element E | E:first-child | The :first-child pseudo-class | Matches element E when E is the first child of its parent | E:nth-child(even|odd) | Structural pseudo-class selector | Matches E element, the even or odd child of its parent | E + F | Adjacent selectors | Matches any F element immediately preceded by a sibling element E | E[foo] | Attribute selectors | Matches any E element with the "foo" attribute set (whatever the value) | E[foo="warning"] | Attribute selectors | Matches any E element whose "foo" attribute value is exactly equal to "warning" | The selectors can be combined or chained.
|