Draws a string into the specified Rect.

Namespace:  C1.Silverlight.Pdf
Assembly:  C1.Silverlight.Pdf (in C1.Silverlight.Pdf.dll)

Syntax

C#
public int DrawString(
	string text,
	Font font,
	Color color,
	Rect rc,
	StringFormat fmt,
	int start
)
Visual Basic
Public Function DrawString ( _
	text As String, _
	font As Font, _
	color As Color, _
	rc As Rect, _
	fmt As StringFormat, _
	start As Integer _
) As Integer

Parameters

text
Type: System..::..String
Text to draw.
font
Type: C1.Silverlight.Pdf..::..Font
Font to use for drawing the text.
color
Type: System.Windows.Media..::..Color
Color of the text.
rc
Type: System.Windows..::..Rect
Rect that specifies the size and position of the text, in points.
fmt
Type: C1.Silverlight.Pdf..::..StringFormat
StringFormat that contains formatting options.
start
Type: System..::..Int32
Index of the first character in the text to draw.

Return Value

The index of the first character in the string that did not fit in the rectangle.

Remarks

The fmt parameter contains properties that specify formatting options. Use the Alignment property to specify horizontal alignment and the LineAlignment property to specify vertical alignment.

Use the FormatFlags property to specify clipping and wrapping.

Use the Angle property to render text at an angle.

The DrawString method returns the index of the first character that was not printed because it did not fit the output rectangle. You can use this value to make text flow from page to page, or from one frame to another within a page.

Due to platform limitations, the Silverlight and WinRT versions of C1Pdf cannot render the full Unicode character set. In these versions of C1Pdf, the DrawString method will only render the "Latin2" character set (characters commonly used in the USA/Canada and Western Europe).

Examples

The code below renders a long string into several pages, using the return value from the DrawString method to determine where to continue printing.
Copy CodeC#
// render string spanning multiple pages
for (int start = 0; start < int.MaxValue;)
{
    // render as much as will fit into the rectangle
    start = _c1pdf.DrawString(text, font, Brushes.Black, rcPage, start);

    // move on to the next page
    _c1pdf.NewPage();
}

See Also