Class Paragraph
A block of text that is wrapped to the available width. Can contain several TextRuns with different fonts, sizes and colors. Line breaks ("\n") are honored. Splits across pages line by line.
public sealed class Paragraph : LayoutElement
- Inheritance
-
Paragraph
- Inherited Members
Constructors
Paragraph()
Creates an empty paragraph; add text with Add(string).
public Paragraph()
Paragraph(string, PdfFont?, double?)
Creates a paragraph with text; a null font or size keeps the default (Helvetica, 10 pt).
public Paragraph(string text, PdfFont? font = null, double? fontSize = null)
Parameters
Properties
Alignment
Horizontal alignment of the lines (default Left).
public TextAlignment Alignment { get; set; }
Property Value
Color
Default text color for runs without their own color (default black).
public PdfColor Color { get; set; }
Property Value
FirstLineIndent
Additional indent of the first line in points, relative to LeftIndent (default 0).
public double FirstLineIndent { get; set; }
Property Value
Font
Default font for runs without their own font (default Helvetica).
public PdfFont Font { get; set; }
Property Value
FontSize
Default font size in points for runs without their own size (default 10).
public double FontSize { get; set; }
Property Value
Hyphenator
Hyphenation for long words (default: DefaultHyphenator). Soft hyphens (U+00AD) are always honored.
public IHyphenator? Hyphenator { get; set; }
Property Value
Kerning
Apply the font's pair kerning (TrueType/OpenType fonts; default true).
public bool Kerning { get; set; }
Property Value
LeftIndent
Left indent of all lines in points (default 0).
public double LeftIndent { get; set; }
Property Value
LineSpacing
Line height as a multiple of the font's natural line height (default 1.15).
public double LineSpacing { get; set; }
Property Value
RightIndent
Right indent of all lines in points (default 0).
public double RightIndent { get; set; }
Property Value
Runs
The text runs in the order they were added.
public IReadOnlyList<TextRun> Runs { get; }
Property Value
Methods
Add(TextRun)
Adds a formatted text run; returns the paragraph.
public Paragraph Add(TextRun run)
Parameters
runTextRun
Returns
Add(string)
Adds text using the paragraph's formatting.
public Paragraph Add(string text)
Parameters
textstring
Returns
Add(string, PdfFont, double?, PdfColor?)
Adds text with its own font (and optionally size and color); returns the paragraph.
public Paragraph Add(string text, PdfFont font, double? fontSize = null, PdfColor? color = null)
Parameters
Returns
AsHeading(int)
Makes the paragraph a heading (H1-H6) in tagged documents; returns the paragraph.
public Paragraph AsHeading(int level)
Parameters
levelint
Returns
SetAlignment(TextAlignment)
Sets Alignment; returns the paragraph.
public Paragraph SetAlignment(TextAlignment alignment)
Parameters
alignmentTextAlignment
Returns
SetColor(PdfColor)
Sets Color; returns the paragraph.
public Paragraph SetColor(PdfColor color)
Parameters
colorPdfColor
Returns
SetFont(PdfFont, double?)
public Paragraph SetFont(PdfFont font, double? size = null)
Parameters
Returns
SetFontSize(double)
Sets FontSize in points; returns the paragraph.
public Paragraph SetFontSize(double size)
Parameters
sizedouble
Returns
SetSpacing(double, double)
Sets the space before and after the paragraph in points; returns the paragraph.
public Paragraph SetSpacing(double before, double after)