Apitron.PDF.Kit library for .NET
Style manager, it's responsible for styles processing and resolving.
Apitron.PDF.Kit (in Apitron.PDF.Kit.dll) Version: 220.127.116.11 (18.104.22.168)
public sealed class StyleManager
Public NotInheritable Class StyleManager
The StyleManager type exposes the following members.
Initializes a new instance of the StyleManager class.
Gets the read-only dictionary which contains registered styles.
Clears this instance by removing all registered styles.
Registers style and provides access to it using its selector. Selector – is a rule that defines which elements should be styled with the given set of properties, it consists of a rule itself that looks very similar to CSS notation and a property set.
- Universal selector (“*”), selects all elements in document, represented as *.
- Type selector (“_typename_”), selects all elements of the given type. E.g. “textbox”. It's possible to list several types using comma, e.g. "textbox, section, image".
- Class selector (“.classname”), selects all elements that belong to specific class. E.g. “*.myclass” selects all elements with class “myclass”.
Because element can have multiple classes set, it is possible to specify several classes in selector, for example “*.myclass1.myclass2”.
- Id selector(“#elementID”). An element can have an id set, and this selector matches the element with specific id. Sample: “texbox#help”, selects the textbox element with ID “help”
Child selector (“[ancestor]>child”), selects all elements that are immediate children of ancestor element, square brackets indicate optionality of the ancestor, in case of absence it will behave like as “*” would be set.
“> textbox” – same as “textbox”, selects all textboxes that are children of any element.
“section > textbox ” – select all textboxes which are placed in sections
“flowdocument > section> textbox.subheader” – selects all textboxes with class ”subheader” set, nested under any section that is a child of root element.
Descendant selector(“element_1 element_2”), selects all elements which are descendants of the given element.
“section#header image” – selects all images in section with ID=”header” regardless of the nesting.
Adjacent element selector (“predessor + element”), selects the element that precedes some element.
“image + textbox” – selects all images that precede a textbox.
How the styles are being resolved:
- Directly assigned value is requested first. It's the value you set using arbitraty property of the content element.
- If no value is set using p.1, we are trying to find its value using selectors and styles registered.
a) look for all selectors that match given element
b) select value according to matching rules (these rules are: specificity of the selector and order of addition, if specificity is the same, we use order)
- Request parent's value if property is inheritable and use the same scheme
In general this styling system is close to CSS used with HTML, so one familiar with the latter can easily find similarities.