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

PdfGraphics.TranslateTransform(Single, Single) Method

Translates the coordinate system origin to the specified point.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v21.1.Drawing.dll

NuGet Package: DevExpress.Pdf.Drawing

Declaration

public void TranslateTransform(
    float x,
    float y
)

Parameters

Name Type Description
x Single

The x-coordinate of the translation.

y Single

The y-coordinate of the translation.

Remarks

This method multiplies the transformation matrix of the PdfGraphics object by a translation matrix. The translation matrix includes the x and y parameters.

The code sample below translates the coordinate system origin and draws shapes in the initial and translated coordinate systems.

Translate the Coordinate System

using DevExpress.Pdf;
using System.Drawing;
//...

using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
    processor.CreateEmptyDocument();
    PdfPage page = processor.AddNewPage(PdfPaperSize.A4);
        using (PdfGraphics graphics = processor.CreateGraphics())
        {
            var rectangle = new RectangleF(0, 0, 300, 300);

            // Draw a green square.
            using (var brush = new SolidBrush(Color.Green))
                graphics.FillRectangle(brush, rectangle);

            // Translate the coordinate system.
            graphics.TranslateTransform(200, 400);

            // Draw a blue square in the translated coordinate system.
            using (var brush = new SolidBrush(Color.Blue))
                graphics.FillRectangle(brush, rectangle);

            // Add graphics content to the document page.
            graphics.AddToPageForeground(page, 72, 72);
        }
    processor.SaveDocument("out2.pdf");
}
Process.Start("out.pdf");

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the TranslateTransform(Single, Single) 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