Back to Devexpress

PdfGraphics.MeasureString(String, DXFont, PdfStringFormat) Method

officefileapi-devexpress-dot-pdf-dot-pdfgraphics-dot-measurestring-x28-system-dot-string-devexpress-dot-drawing-dot-dxfont-devexpress-dot-pdf-dot-pdfstringformat-x29.md

latest2.7 KB
Original Source

PdfGraphics.MeasureString(String, DXFont, PdfStringFormat) Method

Measures the specified string when drawn with the specified font and text formatting parameters.

Namespace : DevExpress.Pdf

Assembly : DevExpress.Pdf.v25.2.Drawing.dll

NuGet Package : DevExpress.Pdf.Drawing

Declaration

csharp
public SizeF MeasureString(
    string text,
    DXFont font,
    PdfStringFormat format
)
vb
Public Function MeasureString(
    text As String,
    font As DXFont,
    format As PdfStringFormat
) As SizeF

Parameters

NameTypeDescription
textString

A text to measure.

| | font | DXFont |

An object that contains font parameters.

| | format | PdfStringFormat |

An object that contains text formatting parameters.

|

Returns

TypeDescription
SizeF

The string’s measured size.

|

Remarks

Use this method to calculate a size of the drawn text. Use the returned SizeF object to calculate a page area or a point where you can draw text.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the MeasureString(String, DXFont, PdfStringFormat) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

office-file-api-ai-implementation/CS/BusinessObjects/Helpers.cs#L219

csharp
// Calculate text size
SizeF textSize = graphics.MeasureString(
    text,

See Also

PdfGraphics Class

PdfGraphics Members

DevExpress.Pdf Namespace