Method DrawText

Namespace
SoftZenPdf
Assembly
SoftZenPdf.dll

DrawText(string, double, double, PdfFont, double, PdfColor?)

Draws a single line of text with its baseline starting at (x, y). Text is not wrapped.

public ContentStreamWriter DrawText(string text, double x, double y, PdfFont font, double size, PdfColor? color = null)

Parameters

text string

The text. With a standard font it must be encodable in WinAnsiEncoding; with a TrueType font every character needs a glyph.

x double

x of the start of the baseline, in points.

y double

y of the baseline, in points.

font PdfFont

A StandardFont or TrueTypeFont.

size double

Font size, in points.

color PdfColor?

Text colour; null keeps the current fill colour (black by default).

Returns

ContentStreamWriter

Remarks

Text is kerned and shaped with the TrueType font's layout tables (ligatures, joined Arabic letters, marks placed on their letters), and right-to-left text such as Hebrew and Arabic is reordered, as described for ShowText(string); TextDirection sets the base direction. Use MeasureText(string, double) to right-align or centre text.

Exceptions

ArgumentException

The font cannot show a character of text.

InvalidOperationException

Called inside a text object, or a standard 14 font is used in a PDF/A document.