PdfGraphics.TranslateTransform(Single, Single) Method
Translates the coordinate system origin to the specified point.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Pdf.v24.2.Drawing.dll
NuGet Package: DevExpress.Pdf.Drawing
#Declaration
#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.
Note
Coordinate system transformations (e.
The code sample below translates the coordinate system origin and draws shapes in the initial and translated coordinate systems.
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");
#Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references 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.