[]
Draws the specified text string in the specified rectangle with the specified Brush and Font objects using the formatting attributes of the specified StringFormat object.
public int DrawString(string text, Font font, Brush brush, RectangleF rc, int firstChar, StringFormat sf)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Brush | brush | Brush object that defines the color of the drawn text. |
RectangleF | rc | The rectangle structure that specifies the location of the drawn text, in points from the top left corner of the page. |
int | firstChar | Index of the first character that will be rendered. |
StringFormat | sf | StringFormat object that specifies formatting attributes applied to the drawn text. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
The sf
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.
To render text in the vertical direction, use the DirectionVertical. By itself, this flag will cause text to render from the bottom to the top of the rectangle. Combined with the 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.
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();
}
Draws the specified text string in the specified rectangle with the specified Brush and Font objects using the formatting attributes of the specified StringFormat object.
public int DrawString(string text, Font font, Color color, RectangleF rc, int firstChar, StringFormat sf)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Color | color | The color of the drawn text. |
RectangleF | rc | The rectangle structure that specifies the location of the drawn text, in points from the top left corner of the page. |
int | firstChar | Index of the first character that will be rendered. |
StringFormat | sf | StringFormat object that specifies formatting attributes applied to the drawn text. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
Draws the specified text string in the specified rectangle, with the specified Brush and Font, using the formatting attributes of the specified StringFormat object and specified character width coefficient.
public int DrawString(string text, Font font, Brush brush, RectangleF rc, int firstChar, StringFormat sf, float widthCoeff)
Type | Name | Description |
---|---|---|
string | text | The string to draw. |
Font | font | The Font used to draw the text. |
Brush | brush | The Brush specifying the text color. |
RectangleF | rc | The rectangle specifying the location of the text, in points from the top left corner of the page. |
int | firstChar | The index of the first character that will be rendered. |
StringFormat | sf | The StringFormat object specifying the formatting attributes applied to the text. |
float | widthCoeff | The width coefficient applied to characters. The default is 1.0, use 2.0 for double width and so on. |
Type | Description |
---|---|
int | The index of the first character that was not rendered because it did not fit in the specified rectangle. |
Draws the specified text string in the specified rectangle, with the specified Brush and Font, using the formatting attributes of the specified StringFormat object and specified character width coefficient.
public int DrawString(string text, Font font, Color color, RectangleF rc, int firstChar, StringFormat sf, float widthCoeff)
Type | Name | Description |
---|---|---|
string | text | The string to draw. |
Font | font | The Font used to draw the text. |
Color | color | The text color. |
RectangleF | rc | The rectangle specifying the location of the text, in points from the top left corner of the page. |
int | firstChar | The index of the first character that will be rendered. |
StringFormat | sf | The StringFormat object specifying the formatting attributes applied to the text. |
float | widthCoeff | The width coefficient applied to characters. The default is 1.0, use 2.0 for double width and so on. |
Type | Description |
---|---|
int | The index of the first character that was not rendered because it did not fit in the specified rectangle. |
Draws the specified text string in the specified rectangle with the specified Brush and Font objects using the formatting attributes of the specified StringFormat object.
public int DrawString(string text, Font font, Color color, RectangleF rc, StringFormat sf)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Color | color | The color of the drawn text. |
RectangleF | rc | The rectangle structure that specifies the location of the drawn text, in points from the top left corner of the page. |
StringFormat | sf | StringFormat object that specifies formatting attributes applied to the drawn text. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
Draws the specified text string in the specified rectangle with the specified Brush and Font objects using the formatting attributes of the specified StringFormat object.
public int DrawString(string text, Font font, Brush brush, RectangleF rc, StringFormat sf)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Brush | brush | The object that defines the color of the drawn text. |
RectangleF | rc | The rectangle structure that specifies the location of the drawn text, in points from the top left corner of the page. |
StringFormat | sf | StringFormat object that specifies formatting attributes applied to the drawn text. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
Draws the specified text string in the specified rectangle with the specified Brush and Font objects using the formatting attributes of the specified StringFormat object.
public int DrawString(string text, Font font, Color color, RectangleF rc, StringFormat sf, float widthCoeff)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Color | color | The color of the drawn text. |
RectangleF | rc | The rectangle structure that specifies the location of the drawn text, in points from the top left corner of the page. |
StringFormat | sf | StringFormat object that specifies formatting attributes applied to the drawn text. |
float | widthCoeff | The width coefficient of text characters, by default 1.0, for double width 2.0. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
Draws the specified text string in the specified rectangle with the specified Brush and Font objects using the formatting attributes of the specified StringFormat object.
public int DrawString(string text, Font font, Brush brush, RectangleF rc, StringFormat sf, float widthCoeff)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Brush | brush | The object that defines the color of the drawn text. |
RectangleF | rc | The rectangle structure that specifies the location of the drawn text, in points from the top left corner of the page. |
StringFormat | sf | StringFormat object that specifies formatting attributes applied to the drawn text. |
float | widthCoeff | The width coefficient of text characters, by default 1.0, for double width 2.0. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
Draws the specified text string in the specified rectangle with the specified Brush and Font objects using the formatting attributes of the specified StringFormat object.
public int DrawString(string text, Font font, Color color, RectangleF rc, int firstChar)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Color | color | The color of the drawn text. |
RectangleF | rc | The rectangle structure that specifies the location of the drawn text, in points from the top left corner of the page. |
int | firstChar | Index of the first character that will be rendered. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
Draws the specified text string in the specified rectangle with the specified Brush and Font objects using the formatting attributes of the specified StringFormat object.
public int DrawString(string text, Font font, Brush brush, RectangleF rc, int firstChar)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Brush | brush | The object that defines the color of the drawn text. |
RectangleF | rc | The rectangle structure that specifies the location of the drawn text, in points from the top left corner of the page. |
int | firstChar | Index of the first character that will be rendered. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
Draws the specified text string in the specified rectangle with the specified Brush and Font objects.
public int DrawString(string text, Font font, Color color, RectangleF rc)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Color | color | The color of the drawn text. |
RectangleF | rc | The rectangle structure that specifies the location of the drawn text, in points from the top left corner of the page. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
This overload renders strings aligned to the top left corner of the specified rectangle, wrapping text as needed within the rectangle, without clipping, and in the horizontal direction. To change any of these defaults, use the overload that allows you to specify a StringFormat parameter.
Draws the specified text string in the specified rectangle with the specified Brush and Font objects.
public int DrawString(string text, Font font, Brush brush, RectangleF rc)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Brush | brush | The object that defines the color of the drawn text. |
RectangleF | rc | The rectangle structure that specifies the location of the drawn text, in points from the top left corner of the page. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
This overload renders strings aligned to the top left corner of the specified rectangle, wrapping text as needed within the rectangle, without clipping, and in the horizontal direction. To change any of these defaults, use the overload that allows you to specify a StringFormat parameter.
Draws the specified text string at the specified point with the specified Brush and Font objects using the formatting attributes of the specified StringFormat object.
public int DrawString(string text, Font font, Color color, PointF pt, StringFormat sf)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Color | color | The object that defines the color of the drawn text. |
PointF | pt | The point structure that specifies the location of the drawn text, in points |
StringFormat | sf | StringFormat object that specifies formatting attributes applied to the drawn text. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
Draws the specified text string at the specified point with the specified Brush and Font objects using the formatting attributes of the specified StringFormat object.
public int DrawString(string text, Font font, Brush brush, PointF pt, StringFormat sf)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Brush | brush | The object that defines the color of the drawn text. |
PointF | pt | The point structure that specifies the location of the drawn text, in points |
StringFormat | sf | StringFormat object that specifies formatting attributes applied to the drawn text. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
Draws the specified text string at the specified point with the specified Brush and Font objects using the formatting attributes of the specified StringFormat object and specified width coefficient of text characters.
public int DrawString(string text, Font font, Color color, PointF pt, StringFormat sf, float widthCoeff)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Color | color | The object that defines the color of the drawn text. |
PointF | pt | The point structure that specifies the location of the drawn text, in points |
StringFormat | sf | StringFormat object that specifies formatting attributes applied to the drawn text. |
float | widthCoeff | The width coefficient of text characters, by default 1.0, for double width 2.0. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
Draws the specified text string at the specified point with the specified Brush and Font objects using the formatting attributes of the specified StringFormat object and specified width coefficient of text characters.
public int DrawString(string text, Font font, Brush brush, PointF pt, StringFormat sf, float widthCoeff)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Brush | brush | The object that defines the color of the drawn text. |
PointF | pt | The point structure that specifies the location of the drawn text, in points |
StringFormat | sf | StringFormat object that specifies formatting attributes applied to the drawn text. |
float | widthCoeff | The width coefficient of text characters, by default 1.0, for double width 2.0. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
public int DrawString(string text, Font font, Color color, PointF pt)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Color | color | The object that defines the color of the drawn text. |
PointF | pt | The point structure that specifies the location of the drawn text, in points from the top left corner of the page. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
public int DrawString(string text, Font font, Brush brush, PointF pt)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Brush | brush | The object that defines the color of the drawn text. |
PointF | pt | The point structure that specifies the location of the drawn text, in points from the top left corner of the page. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
Draws the specified text string at the specified point with the specified Brush, Font objects and specified width coefficient of text characters.
public int DrawString(string text, Font font, Color color, PointF pt, float widthCoeff = 1)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Color | color | The object that defines the color of the drawn text. |
PointF | pt | The point structure that specifies the location of the drawn text, in points from the top left corner of the page. |
float | widthCoeff | The width coefficient of text characters, by default 1.0, for double width 2.0.. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |
Draws the specified text string at the specified point with the specified Brush, Font objects and specified width coefficient of text characters.
public int DrawString(string text, Font font, Brush brush, PointF pt, float widthCoeff = 1)
Type | Name | Description |
---|---|---|
string | text | String to draw. |
Font | font | Font object that defines the appearance and size of the drawn text. |
Brush | brush | The object that defines the color of the drawn text. |
PointF | pt | The point structure that specifies the location of the drawn text, in points from the top left corner of the page. |
float | widthCoeff | The width coefficient of text characters, by default 1.0, for double width 2.0.. |
Type | Description |
---|---|
int | The index of first character that was not printed because it did not fit in the specified rectangle. |