Back to Devexpress

PdfPageTreeObject.Rotate Property

officefileapi-devexpress-dot-pdf-dot-pdfpagetreeobject-a970cdd2.md

latest4.1 KB
Original Source

PdfPageTreeObject.Rotate Property

Rotates the document page at the specified angle.

Namespace : DevExpress.Pdf

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

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public int Rotate { get; set; }
vb
Public Property Rotate As Integer

Property Value

TypeDescription
Int32

An integer value, specifying the page rotation angle (in degrees).

|

Example

The code sample below rotates all document pages.

View Example: How to rotate PDF pages

csharp
using DevExpress.Pdf;

using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
{
    pdfDocumentProcessor.LoadDocument("..\\..\\docs\\TextRotate.pdf");
    int angle = 0;
    foreach (PdfPage page in pdfDocumentProcessor.Document.Pages)
    {
        angle = (angle + 90) % 360;
        page.Rotate = angle;
    }
    pdfDocumentProcessor.SaveDocument("..\\..\\docs\\Rotated.pdf");
}
vb
Imports DevExpress.Pdf

Using pdfDocumentProcessor As New PdfDocumentProcessor()
    pdfDocumentProcessor.LoadDocument("..\..\docs\TextRotate.pdf")
    Dim angle As Integer = 0
    For Each page As PdfPage In pdfDocumentProcessor.Document.Pages
        angle = (angle + 90) Mod 360
        page.Rotate = angle
    Next page
    pdfDocumentProcessor.SaveDocument("..\..\docs\Rotated.pdf")
End Using

The following code snippets (auto-collected from DevExpress Examples) contain references to the Rotate property.

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.

pdf-document-api-add-graphics-to-landscape-and-portrait-pages/CS/CreateGraphics/Program.cs#L50

csharp
float cropBoxHeight = ConvertFromPdfUnits((float)cropBox.Height, dpiY);
switch (page.Rotate)
{

pdf-document-api-rotate-pdf-pages/CS/PdfPageRotationExample/Program.cs#L13

csharp
angle = (angle + 90) % 360;
    page.Rotate = angle;
}

pdf-document-api-add-graphics-to-landscape-and-portrait-pages/VB/CreateGraphics/Program.vb#L44

vb
Dim cropBoxHeight As Single = ConvertFromPdfUnits(CSng(cropBox.Height), dpiY)
Select Case page.Rotate
    Case 90

pdf-document-api-rotate-pdf-pages/VB/PdfPageRotationExample/Program.vb#L12

vb
angle = (angle + 90) Mod 360
    page.Rotate = angle
Next

See Also

PdfPageTreeObject Class

PdfPageTreeObject Members

DevExpress.Pdf Namespace