Skip to main content

PdfGraphics.TextOrigin Property

Specifies how to interpret a point passed to the PdfGraphics.DrawString method as a parameter.

Namespace: DevExpress.Pdf

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

NuGet Package: DevExpress.Pdf.Drawing


public PdfGraphicsTextOrigin TextOrigin { get; set; }

Property Value

Type Description

Indicates the point location relative to the drawn text.

Available values:

Name Description

The point is the top left corner of the text rectangle.


The point is on the text baseline.


Use the TextOrigin property to change the location of a point passed to one of the following DrawString overloads as a parameter:

The image below shows the difference between PdfGraphicsTextOrigin.TopLeftCorner and PdfGraphicsTextOrigin.Baseline values.

TextOrigin Difference

The text point is calculated as follows:

using DevExpress.Pdf;
using System.Drawing;
using (var processor = new PdfDocumentProcessor())

    using (PdfGraphics graphics = processor.CreateGraphics())
        PdfPage page = processor.AddNewPage(PdfPaperSize.A4);
        PdfRectangle pageSize = page.CropBox;

        string text = "DevExpress";
        using (SolidBrush textBrush = new SolidBrush(Color.FromArgb(255, Color.DarkOrange)))
            using (Font font = new Font("Segoe UI", 20, FontStyle.Regular))
                SizeF textSize = graphics.MeasureString(text, font);
                PointF textPoint =
                   new PointF((float)((pageSize.Width - textSize.Width) / 2), (float)((pageSize.Height - textSize.Height) / 2));
                graphics.TextOrigin = PdfGraphicsTextOrigin.Baseline;

                graphics.DrawString(text, font, textBrush, textPoint);
                graphics.AddToPageForeground(page, 72, 72);
See Also