ComponentOne PDF for .NET
C1.C1Pdf Namespace / C1PdfDocument Class / DrawString Method / DrawString(String,Font,Brush,RectangleF,Int32,StringFormat) Method
String to draw.
System.Drawing.Font object that defines the appearance and size of the drawn text.
System.Drawing.Brush object that defines the color of the drawn text.
The rectangle structure that specifies the location of the drawn text, in points from the top left corner of the page.
Index of the first character that will be rendered.
System.Drawing.StringFormat object that specifies formatting attributes applied to the drawn text.
Example

In This Topic
    DrawString(String,Font,Brush,RectangleF,Int32,StringFormat) Method
    In This Topic
    Draws the specified text string in the specified rectangle with the specified System.Drawing.Brush and System.Drawing.Font objects using the formatting attributes of the specified System.Drawing.StringFormat object.
    Syntax
    'Declaration
     
    
    Public Overloads Function DrawString( _
       ByVal text As String, _
       ByVal font As Font, _
       ByVal brush As Brush, _
       ByVal rc As RectangleF, _
       ByVal firstChar As Integer, _
       ByVal sf As StringFormat _
    ) As Integer

    Parameters

    text
    String to draw.
    font
    System.Drawing.Font object that defines the appearance and size of the drawn text.
    brush
    System.Drawing.Brush object that defines the color of the drawn text.
    rc
    The rectangle structure that specifies the location of the drawn text, in points from the top left corner of the page.
    firstChar
    Index of the first character that will be rendered.
    sf
    System.Drawing.StringFormat object that specifies formatting attributes applied to the drawn text.

    Return Value

    The index of first character that was not printed because it did not fit in the specified rectangle.
    Remarks

    The sf contains properties that specify formatting options. Use the System.Drawing.StringFormat.Alignment property to specify horizontal alignment and the System.Drawing.StringFormat.LineAlignment property to specify vertical alignment.

    Use the System.Drawing.StringFormat.FormatFlags property to specify clipping and wrapping.

    To render text in the vertical direction, use the System.Drawing.StringFormatFlags.DirectionVertical. By itself, this flag will cause text to render from the bottom to the top of the rectangle. Combined with the System.Drawing.StringFormatFlags.DirectionRightToLeft flags, it will cause text to render from the top to the bottom of the rectangle.

    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.

    Example
    The code below renders a long string into several pages, using the return value from the DrawString method to determine where to continue printing.
    // 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