[]
        
(Showing Draft Content)

C1.Pdf.C1PdfDocument.MeasureString

MeasureString Method

MeasureString(string, Font, float, StringFormat)

Measures the specified string when drawn with the specified Font object and formatted with the specified StringFormat object.

Declaration
public SizeF MeasureString(string text, Font font, float width, StringFormat sf)
Parameters
Type Name Description
string text

String to measure.

Font font

Font object that defines the appearance and size of the text.

float width

Maximum width of the string.

StringFormat sf

A StringFormat object that determines whether word wrapping is allowed.

Returns
Type Description
SizeF

The size of the string expressed in points.

Implements

MeasureString(string, Font, float, StringFormat, int)

Measures the specified string when drawn with the specified Font object and formatted with the specified StringFormat object.

Declaration
public SizeF MeasureString(string text, Font font, float width, StringFormat sf, int firstChar)
Parameters
Type Name Description
string text

String to measure.

Font font

Font object that defines the appearance and size of the text.

float width

Maximum width of the string.

StringFormat sf

A StringFormat object that determines whether word wrapping is allowed.

int firstChar

The zero-based starting character position of a string.

Returns
Type Description
SizeF

The size of the string expressed in points.

MeasureString(string, Font, float)

Measures the specified string when drawn with a given Font object into a rectangle with the specified width.

Declaration
public SizeF MeasureString(string text, Font font, float width)
Parameters
Type Name Description
string text

String to measure.

Font font

Font object that defines the appearance and size of the text.

float width

Maximum width of the string.

Returns
Type Description
SizeF

The size of the string expressed in points.

Implements
Remarks

This overload wraps the string to prevent any lines from getting wider than the width parameter. The value returned contains the given width and the height needed to render the entire string.

MeasureString(string, Font)

Measures the specified string when drawn with a given Font object.

Declaration
public SizeF MeasureString(string text, Font font)
Parameters
Type Name Description
string text

String to measure.

Font font

Font object that defines the appearance and size of the text.

Returns
Type Description
SizeF

The size of the string expressed in points.

Implements
Remarks

This overload returns the width and height of the string without wrapping. Unless the text parameter contains line break characters, the height returned corresponds to the font height.