Skip to content

PdfParagraph class

View as Markdown

Namespace: PdfNetStack.Drawing
Assembly: PdfNetStack.dll
Package: PdfNetStack

Rich text to lay out: spans of text, each with its own style, and how lines are arranged. Line feeds (\n, \r\n) and U+2029 start a new line; tabs advance four spaces; soft hyphens (U+00AD) mark where a word may break, showing a hyphen when it does.

public sealed class PdfParagraph

Inheritance

object ← PdfParagraph

var body = new PdfTextStyle(inter, 11);
var p = new PdfParagraph { Alignment = PdfTextAlignment.Justify, LineHeight = 1.5 }
    .Add("Invoices are due within ", body)
    .Add("30 days", body with { Font = interBold });
PdfTextLayout layout = g.DrawText(p, 50, 100, 300);   // returns the lines and the height used

Line alignment. Default Start.

public PdfTextAlignment Alignment { get; set; }

PdfTextAlignment

Base direction. Default Auto.

public PdfTextDirection Direction { get; set; }

PdfTextDirection

Indent of the first line, in points.

public double FirstLineIndent { get; set; }

double

Breaks words at the line’s end with a hyphen where this hyphenator allows it, as lines fill. Null, the default, breaks only between words and at soft hyphens. It applies to the whole paragraph, whatever the spans; for text in several languages, insert soft hyphens span by span with InsertSoftHyphens. Text keeps the words as they are, and a break is not offered inside a ligature, which would have to reshape it.

public PdfHyphenator? Hyphenator { get; set; }

PdfHyphenator?

With Justify, right to left Arabic script lines are justified by elongating joined letters with tatweel (kashida) before spaces widen: one elongation per word, up to three tatweel widths, at the point Arabic typography prefers (after seen and sad, before a final heh, dal, alef, lam, kaf, reh or waw, else the last join of the word). Fonts without a tatweel glyph justify with spaces only. Off by default.

public bool Kashida { get; set; }

bool

Line height as a multiple of each span’s font size, as CSS line-height takes a number; null for the font’s own spacing (ascent, descent and line gap), like CSS normal.

public double? LineHeight { get; set; }

double?

The text of all spans.

public string Text { get; }

string

Appends text in a style.

public PdfParagraph Add(string text, PdfTextStyle style)

text string

style PdfTextStyle

PdfParagraph