# Rotate images and PDFs in C# .NET

With Nutrient.NET SDK (formerly GdPicture.NET), it’s possible to rotate PDF pages and images in the following ways:

- PDF
  - [Rotate a PDF page](#rotating-a-pdf-page) — Rotate a selected page by 90, -90, 180, -180, 270, or -270 (or any multiple of 90) degrees.

  - [Rotate a PDF page at any angle](#rotating-a-pdf-page-at-any-angle) — Rotate a selected page by any angle.

  - [Rotate all PDF pages](#rotating-all-pdf-pages) — Rotate all PDF pages by 90, -90, 180, -180, 270, or -270 (or any multiple of 90) degrees.

- Images
  - [Rotate and flip an image](#rotating-and-flipping-an-image) — Rotate an image by 90, -90, 180, -180, 270, or -270 (or any multiple of 90) degrees and flip it around its axis.

  - [Rotate an image at any angle](#rotating-an-image-at-any-angle) – Rotate an image using any angle.

## Rotating a PDF page

To rotate a page of a PDF clockwise by a multiple of 90 degrees, follow these steps:

1. Select the page with the [`SelectPage`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~SelectPage.html) method.

2. Rotate the page with the [`RotatePage`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~RotatePage.html) method. Use multiples of 90 degrees, such as 90, 180, and 270. To rotate a page counterclockwise, use negative values.

The example below rotates the specified page of a PDF file clockwise by 90 degrees:

### C#

```csharp

using GdPicturePDF gdpicturePDF = new GdPicturePDF();
gdpicturePDF.LoadFromFile(@"C:\temp\source.pdf", false);
gdpicturePDF.SelectPage(2);
// Rotate the selected page 90 degrees clockwise.
gdpicturePDF.RotatePage(90);
gdpicturePDF.SaveToFile(@"C:\temp\output.pdf");

```

### VB.NET

```vb

Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    gdpicturePDF.LoadFromFile("C:\temp\source.pdf", False)
    gdpicturePDF.SelectPage(2)
    ' Rotate the selected page 90 degrees clockwise.
    gdpicturePDF.RotatePage(90)
    gdpicturePDF.SaveToFile("C:\temp\output.pdf")
End Using

```

#### Used methods

- [`LoadFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~LoadFromFile.html)

- [`RotatePage`]

- [`SaveToFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~SaveToFile.html)

- [`SelectPage`]

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)

## Rotating a PDF page at any angle

To rotate a PDF page counterclockwise by any angle, use the [`RotatePageEx`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~RotatePageEx.html) method. To rotate a page counterclockwise, use negative values. Before rotating a page, select the page with the [`SelectPage`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~SelectPage.html) method.

To rotate the specified page of a PDF file by -23 degrees, use the following example:

### C#

```csharp

using GdPicturePDF gdpicturePDF = new GdPicturePDF();
    gdpicturePDF.LoadFromFile(@"C:\temp\source.pdf", false);
    gdpicturePDF.SelectPage(2);
    // Rotate the selected page counterclockwise by 23 degrees.
    gdpicturePDF.RotatePageEx(-23);
    gdpicturePDF.SaveToFile(@"C:\temp\output.pdf");

```

### VB.NET

```vb

Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    gdpicturePDF.LoadFromFile("C:\temp\source.pdf", False)
    gdpicturePDF.SelectPage(2)
    ' Rotate the selected page counterclockwise by 23 degrees.
    gdpicturePDF.RotatePageEx(-23)
    gdpicturePDF.SaveToFile("C:\temp\output.pdf")
End Using

```

#### Used methods

- [`LoadFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~LoadFromFile.html)

- [`RotatePageEx`]

- [`SaveToFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~SaveToFile.html)

- [`SelectPage`]

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)

## Rotating all PDF pages

To rotate all PDF pages clockwise at the same angle at once, use the [`RotatePages`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~RotatePages.html) method. This method accepts multiples of 90 degrees, such as 90, 180, and 270. To rotate a page counterclockwise, use negative values.

To rotate all pages of a PDF file by -270 degrees, use the following example:

### C#

```csharp

using GdPicturePDF gdpicturePDF = new GdPicturePDF();
gdpicturePDF.LoadFromFile(@"C:\temp\source.pdf", false);
// Rotate the selected page counterclockwise by 270 degrees.
gdpicturePDF.RotatePages(-270);
gdpicturePDF.SaveToFile(@"C:\temp\output.pdf");

```

### VB.NET

```vb

Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    gdpicturePDF.LoadFromFile("C:\temp\source.pdf", False)
    ' Rotate the selected page counterclockwise by 270 degrees.
    gdpicturePDF.RotatePages(-270)
    gdpicturePDF.SaveToFile("C:\temp\output.pdf")
End Using

```

#### Used methods

- [`LoadFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~LoadFromFile.html)

- [`SaveToFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~SaveToFile.html)

- [`RotatePages`]

#### Related Topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)

## Rotating and flipping an image

To both rotate and flip an image by multiples of 90 degrees, such as 90, 180, and 270, use the [`Rotate`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~Rotate.html) method. To rotate counterclockwise, use negative values. This method requires the `RotateFlipType` enumeration, which specifies the angle by which the image is rotated and how it’s flipped. For more information, refer to the [`RotateFlipType`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14%20(COM%20-%20ActiveX)~GdPicture14.RotateFlipType.html) enumeration.

The `RotateFlipType` enumeration is provided in the.NET COM interop edition only. Applications linking other editions must use the `System.Drawing.RotateFlipType` enumeration.

To rotate an image 270 degrees and flip it on its Y axis, use the following example:

### C#

```csharp

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"C:\temp\source.jpg");
// Rotate the image by 270 degrees clockwise and flip it on its Y axis.
gdpictureImaging.Rotate(imageID, RotateFlipType.Rotate270FlipY);
gdpictureImaging.SaveAsJPEG(imageID, @"C:\temp\output.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("C:\temp\source.jpg")
    ' Rotate the image by 270 degrees clockwise and flip it on its Y axis.
    gdpictureImaging.Rotate(imageID, RotateFlipType.Rotate270FlipY)
    gdpictureImaging.SaveAsJPEG(imageID, "C:\temp\output.jpg", 75)
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using

```

#### Used methods

- [`CreateGdPictureImageFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~CreateGdPictureImageFromFile.html)

- [`ReleaseGdPictureImage`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html)

- [`Rotate`]

- [`SaveAsJPEG`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~SaveAsJPEG.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)

## Rotating an image at any angle

To rotate an image clockwise by any angle, use the [`RotateAngle`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~RotateAngle.html) method. To rotate a page counterclockwise, use negative values.

To rotate an image by -23 degrees, use the following example:

### C#

```csharp

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"C:\temp\source.jpg");
// Rotate the image counterclockwise by 23 degrees.
gdpictureImaging.RotateAngle(imageID, -23);
gdpictureImaging.SaveAsJPEG(imageID, @"C:\temp\output.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("C:\temp\source.jpg")
    ' Rotate the image counterclockwise by 23 degrees.
    gdpictureImaging.RotateAngle(imageID, -23)
    gdpictureImaging.SaveAsJPEG(imageID, "C:\temp\output.jpg", 75)
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using

```

#### Used methods

- [`CreateGdPictureImageFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~CreateGdPictureImageFromFile.html)

- [`ReleaseGdPictureImage`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html)

- [`RotateAngle`]

- [`SaveAsJPEG`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~SaveAsJPEG.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)
---

## Related pages

- [Blur images in C# .NET](/guides/dotnet/editor/manipulation/blur.md)
- [Set image or PDF colors in C#](/guides/dotnet/editor/manipulation/colors.md)
- [Replace colors in an image](/guides/dotnet/editor/manipulation/replace-colors-from-image.md)
- [Extract pages from a PDF in C#](/guides/dotnet/editor/manipulation/extract.md)
- [Remove pages from PDFs in C#](/guides/dotnet/editor/manipulation/remove-page.md)
- [Crop images in C# .NET](/guides/dotnet/editor/manipulation/crop.md)
- [Image filters using C# .NET](/guides/dotnet/editor/manipulation/filters.md)
- [Move or copy PDF pages and TIFF images in C#](/guides/dotnet/editor/manipulation/move-or-copy-page.md)
- [PDF and image manipulation in C# .NET](/guides/dotnet/editor/manipulation.md)

