Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+
Box

PageCanvas.ConvertToDrawingLayoutUnits(Rectangle, DocumentLayoutUnit) Method

Converts an object’s measurement units to the specified ones.

Namespace: DevExpress.XtraRichEdit.API.Layout

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

Declaration

public Rectangle ConvertToDrawingLayoutUnits(
    Rectangle rect,
    DocumentLayoutUnit unit
)

Parameters

Name Type Description
rect Rectangle

A Rectangle structure that will be measured in the specified unit.

unit DocumentLayoutUnit

Specifies measurement units for structure parameters.

Returns

Type Description
Rectangle

A Rectangle structure that is the original rectangle, converted to specific document layout units.

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

This method is effective only if the drawn shape has coordinates and parameters represented by absolute values. There is no need to convert parameters represented by relative values – they are already measured in the same unit as the document layout.

Example

This code snippet illustrates the implementation of the PageCanvas.ConvertToDrawingLayoutUnits method.

In this example, a custom colored rectangle is drawn. The PageCanvas.ConvertToDrawingLayoutUnits method converts its parameters to the same measurement units as the one specified for the document layout. It makes the drawn figure appear the same in Print Preview and on the display:

PagePainter Applied

If the method is not used and the rectangle’s parameters are not converted, it will appear as illustrated below:

PagePainter NotApplied

Public Overrides Sub DrawPage(ByVal page As LayoutPage)
    If Form1.customDrawPage = True Then
        Dim inlineRect As New Rectangle(100, 100, 150, 200)
        Canvas.DrawRectangle(New RichEditPen(Color.Aquamarine, Canvas.ConvertToDrawingLayoutUnits(4, DocumentLayoutUnit.Pixel)), Canvas.ConvertToDrawingLayoutUnits(inlineRect, DocumentLayoutUnit.Pixel))

    End If
    MyBase.DrawPage(page)
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the ConvertToDrawingLayoutUnits(Rectangle, DocumentLayoutUnit) 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.

See Also