Back to Devexpress

PdfGraphics.ScaleTransform(Single, Single) Method

officefileapi-devexpress-dot-pdf-dot-pdfgraphics-dot-scaletransform-x28-system-dot-single-system-dot-single-x29.md

latest3.7 KB
Original Source

PdfGraphics.ScaleTransform(Single, Single) Method

Scales the coordinate system by the specified scale factor.

Namespace : DevExpress.Pdf

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

NuGet Package : DevExpress.Pdf.Drawing

Declaration

csharp
public void ScaleTransform(
    float sx,
    float sy
)
vb
Public Sub ScaleTransform(
    sx As Single,
    sy As Single
)

Parameters

NameTypeDescription
sxSingle

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 following scales the coordinate system and draws shapes in the initial and scaled coordinate systems.

csharp
using DevExpress.Pdf;
using DevExpress.Drawing;
//...

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

            // Draw a blue square.
            using (var brush = new DXSolidBrush(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 DXSolidBrush(Color.Red))
                graphics.FillRectangle(brush, rectangle);

            // Add graphics content to the document page.
            graphics.AddToPageForeground(page);
        }
    processor.SaveDocument("out2.pdf");
}
Process.Start("out.pdf");
vb
Imports DevExpress.Pdf
Imports DevExpress.Drawing
'...

Using processor As New PdfDocumentProcessor()
    processor.CreateEmptyDocument()
    Dim page As PdfPage = processor.AddNewPage(PdfPaperSize.A4)
        Using graphics As PdfGraphics = processor.CreateGraphicsWorldSystem()
            Dim rectangle = New RectangleF(0, 0, 300, 300)

            ' Draw a blue square.
            Using brush = New DXSolidBrush(Color.Blue)
                graphics.FillRectangle(brush, rectangle)
            End Using

            ' Scale the coordinate system.
            graphics.ScaleTransform(0.5F, 0.5F)

            ' Draw a red square in the scaled coordinate system.
            Using brush = New DXSolidBrush(Color.Red)
                graphics.FillRectangle(brush, rectangle)
            End Using

            ' Add graphics content to the document page.
            graphics.AddToPageForeground(page)
        End Using
    processor.SaveDocument("out2.pdf")
End Using
Process.Start("out.pdf")

See Also

PdfGraphics Class

PdfGraphics Members

DevExpress.Pdf Namespace