Class RepTextMM
Represents a text object for a formatted single or multiline text in a PDF report, where the dimensions are in millimeters.
public class RepTextMM : RepText
- Inheritance
-
RepTextMM
- Inherited Members
Examples
StandardFontDef fontDef = new(StandardFont.Helvetica);
FontProp font = new(fontDef, 10);
new RepTextMM(font, $"The {RepText.BoldOn}area{RepText.BoldOff} is 2000 m{RepText.Superscript("2")} in size.", 50);
Result: The area is 2000 m2 in size.
Constructors
RepTextMM(FontProp, string, double, TextOptions)
Initializes a new instance of the RepTextMM class with the specified font, text, maximum width in millimeters and text options.
public RepTextMM(FontProp font, string text, double widthMM, TextOptions options = TextOptions.None)
Parameters
font
FontPropThe font for the string.
text
stringThe text.
widthMM
doubleThe maximum width of a line in millimeters.
options
TextOptionsThe text options for the text.
Remarks
The text is automatically wrapped into lines if it is too long.
A line break is forced by \n
.
Automatic wrapping occurs at spaces or hyphens if there is a letter before and after.
If a word no longer fits on the line, it is written on the next line.
An automatic line break removes all spaces between the two words where the line break occurs.
If a word is wider than the text box and cannot be separated regularly, it is wrapped as best as possible within the word.
If a letter is wider than the text box, the letter is displayed in one line and determines the width of the text box.
Spaces at the beginning of a new line cause the text to be indented by the spaces.
Spaces at the end of the text are displayed up to the end of the line.
There are two ways to format text: escape sequences and HTML tags (see TextOptions.Html).
Character / Excape Sequence | HTML Tags | Description |
---|---|---|
\r | - | will be ignored |
\n | - | new line |
All other characters in the range of 0..31 | - | cannot be used and will throw an exception |
BoldOn, BoldOff, Bold(string) | <b> </b> | Sets the font style to bold . |
ItalicOn, ItalicOff, Italic(string) | <i> </i> | Sets the font style to italic . |
UnderlineOn, UnderlineOff, Underline(string) | <u> </u> | Sets the font style to underline . |
StrikethroughOn, StrikethroughOff, Strikethrough(string) | <s> </s> | Sets the font style to strikethrough . |
SubscriptOn, SubscriptOff, Subscript(string) | <sub> </sub> | Sets the font style to subscript . |
SuperscriptOn, SuperscriptOff, Superscript(string) | <sup> </sup> | Sets the font style to superscript . |
FontSize(double), FontSizeMM(double) | - | Sets the font size. |
FontColor(Color) | - | Sets the font color. |
BackgroundOn, BackgroundOff, Background(Color) | <mark> </mark> | Sets the background used to highlight text. |
Supported text options:
TextOption | Description |
---|---|
None | No special formatting. |
Center | Each line of text is centered. |
Right | Each line of text is right-aligned. |
AdjustWidth | The width of the bounding box is set to the longest line of text. |
Html | The text contains HTML formatting. |
A text object can be splitted on multiple pages, see class VerticalObjectSplitter and example Flow Text Report.
Exceptions
- ArgumentNullException
The font or text is null.
- ArgumentOutOfRangeException
The width is less than or equal to zero.
- ArgumentException
Invalid option:
TruncateIfTooLong
,EllipsisIfTooLong
,SmallerFontIfToolLong
orCenter
together withRight
are not allowed.