DocumentSettings
DocumentSettings is a struct you construct before creating a DocumentController.
After creation, you can update it at any time by calling
controller.ApplyDocumentSettings(newSettings).
| Property | Type | Default | Description |
|---|---|---|---|
| DocumentBackgroundColor | SKColor | White | Page background color painted behind all text and images. |
| TextStyle | IStyle | — | Default text style applied when no explicit style exists. Set font family, size, and color here. |
| PageWidth | float | 800 | Total page width in pixels (including margins). |
| DocumentMargins | DocumentMargins | default | Left, right, top, and bottom margin values in pixels. |
| Alignment | TextAlignment | Left | Default paragraph alignment for new paragraphs. |
var settings = new DocumentSettings
{
PageWidth = 850f,
DocumentBackgroundColor = SKColors.White,
DocumentMargins = new DocumentMargins(80, 80, 60, 60),
TextStyle = new Style { FontFamily = "Segoe UI", FontSize = 13 },
Alignment = TextAlignment.Left
};
DocumentMargins
structAll properties are init-only and specified in pixels.
| Property | Type | Description |
|---|---|---|
| Left | float | Left margin in pixels |
| Right | float | Right margin in pixels |
| Top | float | Top margin in pixels |
| Bottom | float | Bottom margin in pixels |
// Constructor form
var margins = new DocumentMargins(80, 80, 60, 60);
// left=80, right=80, top=60, bottom=60
// Or object-initializer form
var margins = new DocumentMargins { Left = 100, Right = 100, Top = 80, Bottom = 80 };
DocumentInfo
structA read-only snapshot of the document's current dimensions, delivered via the OnContentSizeChanged event.
| Property | Type | Description |
|---|---|---|
| Width | float | Total document width as measured |
| Height | float | Total document height as measured |
| ScrollOffset | Vector2 | Current scroll position (X, Y) |
NavigationInfo
structPublished via DocumentController.OnNavigation when the caret moves or the style changes.
| Property | Type | Description |
|---|---|---|
| StyleAtCaret | IStyle | Fully merged text style at the current caret position |
| SelectionInfo | SelectionInfo | Paragraph-level info: alignment, list type/level, line spacing |
| Selection | TextRange | The current selection range (start == end when no selection) |
controller.OnNavigation += (info) =>
{
var style = info.StyleAtCaret;
boldBtn.IsChecked = style.FontWeight >= 700;
italicBtn.IsChecked = style.FontItalic == true;
var sel = info.SelectionInfo;
alignLeft.IsChecked = sel.Alignment == TextAlignment.Left;
alignCenter.IsChecked = sel.Alignment == TextAlignment.Center;
bulletBtn.IsChecked = sel.ListType == ListType.Bullet;
};
IStyle Properties
IStyle is defined by Topten.RichTextKit. All properties are nullable — null means
"inherit from the document default."
| Property | Type | Description |
|---|---|---|
| FontFamily | string? | Font family name (e.g., "Arial") |
| FontSize | float? | Font size in points |
| FontWeight | int? | 400 = normal, 700 = bold |
| FontItalic | bool? | True for italic |
| TextColor | SKColor? | Foreground text color |
| BackgroundColor | SKColor? | Background highlight color |
| Underline | UnderlineStyle? | None or Solid |
| StrikeThrough | StrikeThroughStyle? | None or Solid |
| FontVariant | FontVariant? | Normal, SubScript, or SuperScript |