Skip to main content
Box

PageCanvas.DrawString(String, Font, RichEditBrushBase, Point, DocumentLayoutUnit) Method

Draws a custom string.

Namespace: DevExpress.XtraRichEdit.API.Layout

Assembly: DevExpress.RichEdit.v24.1.Core.dll

NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation

Declaration

public void DrawString(
    string str,
    Font font,
    RichEditBrushBase brush,
    Point point,
    DocumentLayoutUnit unit
)

Parameters

Name Type Description
str String

A custom string to be drawn.

font Font

Sets the string’s font parameters.

brush RichEditBrushBase

The RichEditBrushBase descendant that sets the string characters’ color and thickness.

point Point

Sets the string’s start point coordinates.

unit DocumentLayoutUnit

Specifies measurement units for string parameters.

Remarks

When you print or export documents, document objects may appear differently from the way they look on screen. To make them look the same in both outputs, set the DocumentLayoutUnit parameter to the same DocumentLayoutUnit value as the one specified for the document layout.

Note

Using this parameter is effective only if the drawn shape has coordinates and parameters represented by absolute values – coordinates represented by relative values already have the same measurement unit as the whole document layout.

Example

This code snippet illustrates the implementation of the PageCanvas.DrawLine and PageCanvas.DrawString methods. They draw two color lines and two strings in place of the header.

One line was drawn without setting the DocumentLayoutUnit parameter, the other was drawn with this parameter set to the same DocumentLayoutUnit value as the one specified for the document layout.

HeaderPainter Display

The line with the set parameter will look the same both in Print Preview and on display, whereas the other will look different in Print Preview.

HeaderPainter PrintPreview

View Example

Public Overrides Sub DrawHeader(ByVal header As LayoutHeader)
    If Form1.customDrawHeader = True Then

        Dim p1 As New Point(0, 0)
        Dim p2 As New Point(100, 100)
        Canvas.DrawLine(New RichEditPen(Color.Red, 5), p1, p2)
        Canvas.DrawString("Default Layout Unit", New Font("Comic Sans", 12), New RichEditBrush(Color.Red), New Point(0, 0))
        Dim p3 As New Point(0, 100)
        Dim p4 As New Point(100, 200)
        Canvas.DrawLine(New RichEditPen(Color.Blue, 5), p3, p4, DocumentLayoutUnit.Pixel)
        Canvas.DrawString("Layout Unit Specified", New Font("Comic Sans", 12), New RichEditBrush(Color.Blue), New Point(0, 100), DocumentLayoutUnit.Pixel)
    Else
        MyBase.DrawHeader(header)
    End If
End Sub
See Also