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

PdfGraphics.ScaleTransform(Single, Single) Method

Scales the coordinate system by the specified scale factor.

Namespace: DevExpress.Pdf

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

NuGet Package: DevExpress.Pdf.Drawing

Declaration

public void ScaleTransform(
    float sx,
    float sy
)

Parameters

Name Type Description
sx Single

Scale factor in the x direction.

sy Single

Scale factor in the y direction.

Remarks

This method multiplies the transformation matrix of the PdfGraphics object by a scaling matrix. The scaling matrix is a diagonal matrix that includes the sx and sy parameters.

Example

The code sample below scales the coordinate system and draws shapes in the initial and scaled coordinate systems.

Scale 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 blue square.
            using (var brush = new SolidBrush(Color.Blue))
                graphics.FillRectangle(brush, rectangle);

            // Scale the coordinate system.
            graphics.ScaleTransform(0.5f, 0.5f);

            // Draw a red square in the scaled coordinate system.
            using (var brush = new SolidBrush(Color.Red))
                graphics.FillRectangle(brush, rectangle);

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