Method DrawText
- Namespace
- BitMiracle.Docotic.Pdf
- Assembly
- BitMiracle.Docotic.Pdf.dll
DrawText(string, PdfTextDrawingOptions)
Draws the specified text string using the specified formatting options.
public int DrawText(string text, PdfTextDrawingOptions options)
Parameters
textstringThe text to draw.
optionsPdfTextDrawingOptionsThe drawing options.
Returns
- int
The number of drawn characters.
Remarks
This method allows you to draw single-line or multi-line text within a Bounds rectangle. The text is clipped so that it does not appear outside the specified rectangle.
Lines are automatically broken between words if a word would extend past the edge of the bounding rectangle. A carriage return-line feed sequence also breaks the line.
Use DrawString methods if you want to draw only one line of text at the specified position.
For a simpler, higher-level approach to adding text to PDF pages, consider using the Layout API. It provides convenient abstractions for working with text, headers, footers, and other page elements without manually handling drawing bounds.
Exceptions
- ArgumentException
textcontains an invalid surrogate pair. Either the first character in the pair is not a valid high surrogate or the second character in the pair is not a valid low surrogate.- CannotShowTextException
textcontains a glyph that cannot be drawn using the current Font and cannot be substituted using theoptions.MissingGlyphHandler.