Table of Contents

Class Paragraph

Namespace
MiPdf.Layout
Assembly
MiPdf.dll

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

text string
font PdfFont
fontSize double?

Properties

Alignment

Horizontal alignment of the lines (default Left).

public TextAlignment Alignment { get; set; }

Property Value

TextAlignment

Color

Default text color for runs without their own color (default black).

public PdfColor Color { get; set; }

Property Value

PdfColor

FirstLineIndent

Additional indent of the first line in points, relative to LeftIndent (default 0).

public double FirstLineIndent { get; set; }

Property Value

double

Font

Default font for runs without their own font (default Helvetica).

public PdfFont Font { get; set; }

Property Value

PdfFont

FontSize

Default font size in points for runs without their own size (default 10).

public double FontSize { get; set; }

Property Value

double

Hyphenator

Hyphenation for long words (default: DefaultHyphenator). Soft hyphens (U+00AD) are always honored.

public IHyphenator? Hyphenator { get; set; }

Property Value

IHyphenator

Kerning

Apply the font's pair kerning (TrueType/OpenType fonts; default true).

public bool Kerning { get; set; }

Property Value

bool

LeftIndent

Left indent of all lines in points (default 0).

public double LeftIndent { get; set; }

Property Value

double

LineSpacing

Line height as a multiple of the font's natural line height (default 1.15).

public double LineSpacing { get; set; }

Property Value

double

RightIndent

Right indent of all lines in points (default 0).

public double RightIndent { get; set; }

Property Value

double

Runs

The text runs in the order they were added.

public IReadOnlyList<TextRun> Runs { get; }

Property Value

IReadOnlyList<TextRun>

Methods

Add(TextRun)

Adds a formatted text run; returns the paragraph.

public Paragraph Add(TextRun run)

Parameters

run TextRun

Returns

Paragraph

Add(string)

Adds text using the paragraph's formatting.

public Paragraph Add(string text)

Parameters

text string

Returns

Paragraph

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

text string
font PdfFont
fontSize double?
color PdfColor?

Returns

Paragraph

AsHeading(int)

Makes the paragraph a heading (H1-H6) in tagged documents; returns the paragraph.

public Paragraph AsHeading(int level)

Parameters

level int

Returns

Paragraph

SetAlignment(TextAlignment)

Sets Alignment; returns the paragraph.

public Paragraph SetAlignment(TextAlignment alignment)

Parameters

alignment TextAlignment

Returns

Paragraph

SetColor(PdfColor)

Sets Color; returns the paragraph.

public Paragraph SetColor(PdfColor color)

Parameters

color PdfColor

Returns

Paragraph

SetFont(PdfFont, double?)

Sets Font and, if given, FontSize; returns the paragraph.

public Paragraph SetFont(PdfFont font, double? size = null)

Parameters

font PdfFont
size double?

Returns

Paragraph

SetFontSize(double)

Sets FontSize in points; returns the paragraph.

public Paragraph SetFontSize(double size)

Parameters

size double

Returns

Paragraph

SetSpacing(double, double)

Sets the space before and after the paragraph in points; returns the paragraph.

public Paragraph SetSpacing(double before, double after)

Parameters

before double
after double

Returns

Paragraph