officefileapi-devexpress-dot-pdf-dot-pdfgraphics-dot-drawstring-x28-system-dot-string-devexpress-dot-drawing-dot-dxfont-devexpress-dot-drawing-dot-dxsolidbrush-system-dot-drawing-dot-pointf-x29.md
Draws text with the specified brush and font parameters at the specified page point.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Drawing.dll
NuGet Package : DevExpress.Pdf.Drawing
public void DrawString(
string text,
DXFont font,
DXSolidBrush brush,
PointF point
)
Public Sub DrawString(
text As String,
font As DXFont,
brush As DXSolidBrush,
point As PointF
)
| Name | Type | Description |
|---|---|---|
| text | String |
A text to draw.
| | font | DXFont |
An object that defines font options.
| | brush | DXSolidBrush |
An object that determines the color and texture of the drawn text.
| | point | PointF |
A point in the world coordinate system where you can position text.
|
Use the MeasureString method to calculate the size of the drawn text and a point where you can draw text.
The point parameter define the point where the text’s upper-left corner is located. Set the TextOrigin property to Baseline to make the point parameter define the point where the start of the text’s baseline is located. Set this property before the DrawString method call.
Use the UseKerning property to enable kerning in drawn text.
To draw a string on the PDF page, use one of the following methods:
PdfGraphics.AddToPageForeground, PdfGraphics.AddToPageBackgroundThese methods allow you to draw content on an existing page.PdfDocumentProcessor.RenderNewPageDraws content on a new page.
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DrawString(String, DXFont, DXSolidBrush, PointF) 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.
pdf-document-api-add-graphics-to-landscape-and-portrait-pages/CS/CreateGraphics/Program.cs#L38
PointF bottomRight = new PointF(actualPageSize.Width - textSize.Width, actualPageSize.Height - textSize.Height);
graphics.DrawString(text, font, textBrush, topLeft);
graphics.DrawString(text, font, textBrush, bottomRight);
pdf-document-api-add-graphics-to-landscape-and-portrait-pages/VB/CreateGraphics/Program.vb#L33
Dim bottomRight As PointF = New PointF(actualPageSize.Width - textSize.Width, actualPageSize.Height - textSize.Height)
graphics.DrawString(text, font, textBrush, topLeft)
graphics.DrawString(text, font, textBrush, bottomRight)
See Also