> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/core/page-manipulation/rotate.md).

# Rotating a PDF page on Server/Desktop

Learn how to rotate pages in a PDF document easily with this helpful guide. Find out how to rotate pages clockwise by 90 degrees for better viewing and printing results. The Apryse Server SDK streamli

{% hint style="info" %}
**Requirements**

Packages are required for production license. Trial keys have unlimited access to all features.

Demo showcases functionality using WebViewer UI.

<a href="https://apryse.com/capabilities#PageManipulation" class="button primary">Package: Page Manipulation</a><a href="https://showcase.apryse.com/create-thumbnail" class="button primary">Live demo</a>
{% endhint %}

To rotate a page in a PDF document.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
PDFDoc doc = new PDFDoc(filename);

// Rotate the first page 90 degrees clockwise.
Page page = doc.GetPage(1);
Page.Rotate originalRotation = page.GetRotation();
Page.Rotate rotation;
switch (originalRotation)
{
  case Page.Rotate.e_0:   rotation = Page.Rotate.e_90;  break;
  case Page.Rotate.e_90:  rotation = Page.Rotate.e_180; break;
  case Page.Rotate.e_180: rotation = Page.Rotate.e_270; break;
  case Page.Rotate.e_270: rotation = Page.Rotate.e_0;   break;
  default:                rotation = Page.Rotate.e_0;   break;
}
page.SetRotation(rotation);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
PDFDoc doc(filename);

// Rotate the first page 90 degrees clockwise.
Page page = doc.GetPage(1);
Page::Rotate originalRotation = page.GetRotation();
Page::Rotate rotation;
switch (originalRotation)
{
  case Page::e_0:   rotation = Page::e_90;  break;
  case Page::e_90:  rotation = Page::e_180; break;
  case Page::e_180: rotation = Page::e_270; break;
  case Page::e_270: rotation = Page::e_0;   break;
  default:          rotation = Page::e_0;   break;
}
page.SetRotation(rotation);
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
doc := NewPDFDoc(filename)

// Rotate the first page 90 degrees clockwise.
page := doc.GetPage(1)
originalRotation := page.GetRotation()
var rotation int
if originalRotation == PageE_0 {
  rotation = PageE_90
}
else if originalRotation == PageE_90 {
  rotation = PageE_180
}
else if originalRotation == PageE_180 {
  rotation = PageE_270
}
else if originalRotation == PageE_270 {
  rotation = PageE_0
}
else {
  rotation = Page::E_0
}
page.SetRotation(rotation)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
PDFDoc doc = new PDFDoc(filename);

// Rotate the first page 90 degrees clockwise.
Page page = doc.getPage(1);
int originalRotation = page.getRotation();
int rotation;
switch (originalRotation)
{
  case Page.e_0:   rotation = Page.e_90;  break;
  case Page.e_90:  rotation = Page.e_180; break;
  case Page.e_180: rotation = Page.e_270; break;
  case Page.e_270: rotation = Page.e_0;   break;
  default:         rotation = Page.e_0;   break;
}
page.setRotation(rotation);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
async function main() {
  const doc = await PDFNet.PDFDoc.createFromURL(filename);

  // Rotate the first page 90 degrees clockwise.
  const page = await doc.getPage(1);
  const originalRotation = await page.getRotation();
  var rotation;
  switch (originalRotation)
  {
    case Page.e_0:   rotation = Page.e_90;  break;
    case Page.e_90:  rotation = Page.e_180; break;
    case Page.e_180: rotation = Page.e_270; break;
    case Page.e_270: rotation = Page.e_0;   break;
    default:         rotation = Page.e_0;   break;
  }
  page.setRotation(rotation);
}
PDFNet.runWithCleanup(main);
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
val doc = PDFDoc(filename)

// Rotate the first page 90 degrees clockwise.
val page = doc.getPage(1)
val originalRotation = page.getRotation()
val rotation = when (originalRotation)
{
  Page.e_0    -> Page.e_90
  Page.e_90   -> Page.e_180
  Page.e_180  -> Page.e_270
  Page.e_270  -> Page.e_0
  else        -> Page.e_0
}
page.setRotation(rotation)
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
PTPDFDoc *doc = [[PTPDFDoc alloc] initWithFilepath: filename];

// Rotate the first page 90 degrees clockwise.
PTPage *page = [doc GetPage:1];
PTRotate originalRotation = [page getRotation];
PTRotate rotation;
switch (originalRotation)
{
  case e_pt0:   rotation = e_pt90;  break;
  case e_pt90:  rotation = e_pt180; break;
  case e_pt180: rotation = e_pt270; break;
  case e_pt270: rotation = e_pt0;   break;
  default:      rotation = e_pt0;   break;
}
[page SetRotation: rotation];
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
let doc: PTPDFDoc = PTPDFDoc(filepath: filename)

// Rotate the first page 90 degrees clockwise.
let page: PTPage = doc.getPage(1)
let originalRotation: PTRotate = page.getRotation()
var rotation: PTRotate
switch (originalRotation)
{
  case e_pt0:   rotation = e_pt90
  case e_pt90:  rotation = e_pt180
  case e_pt180: rotation = e_pt270
  case e_pt270: rotation = e_pt0
  default:      rotation = e_pt0
}
page.setRotation(rotation)
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$doc = new PDFDoc($filename);

// Rotate the first page 90 degrees clockwise.
$page = $doc->GetPage(1);
$originalRotation = $page->GetRotation();
$rotation = NULL;
switch ($originalRotation)
{
  case Page::e_0:   $rotation = Page::e_90;  break;
  case Page::e_90:  $rotation = Page::e_180; break;
  case Page::e_180: $rotation = Page::e_270; break;
  case Page::e_270: $rotation = Page::e_0;   break;
  default:          $rotation = Page.Rotate.e_0;   break;
}
$page->SetRotation($rotation);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
doc = PDFDoc(filename)

# Rotate the first page 90 degrees clockwise.
page = doc.GetPage(1)
originalRotation = page.GetRotation()
rotation = None
if originalRotation == Page.e_0:
  rotation = Page.e_90
elif originalRotation == Page.e_90:
  rotation = Page.e_180
elif originalRotation == Page.e_180:
  rotation = Page.e_270
elif originalRotation == Page.e_270:
  rotation = Page.e_0
else
  rotation = Page.e_0
page.SetRotation(rotation)
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
doc = PDFDoc.new(filename)

# Rotate the first page 90 degrees clockwise.
page = doc.GetPage(1)
originalRotation = page.GetRotation()
rotation = nil
if originalRotation == Page::E_0
  rotation = Page::E_90
elsif originalRotation == Page::E_90
  rotation = Page::E_180
elsif originalRotation == Page::E_180
  rotation = Page::E_270
elsif originalRotation == Page::E_270
  rotation = Page::E_0
else
  rotation = Page::E_0
end
page.SetRotation(rotation)
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
Dim doc4 As PDFDoc = New PDFDoc(filename)

' Rotate the first page 90 degrees clockwise.
Dim page As Page = doc.GetPage(1)
Dim originalRotation As Page.Rotate = page.GetRotation()
Dim rotation As Page.Rotate
If originalRotation == Page.Rotate.e_0 Then
  rotation = Page.Rotate.e_90
ElseIf originalRotation == Page.Rotate.e_90 Then
  rotation = Page.Rotate.e_180
ElseIf originalRotation == Page.Rotate.e_180 Then
  rotation = Page.Rotate.e_270
ElseIf originalRotation == Page.Rotate.e_270 Then
  rotation = Page.Rotate.e_0
Else
  rotation = Page.Rotate.e_0
End If
page.SetRotation(rotation)
```

{% endcode %}
{% endtab %}
{% endtabs %}

## About rotating pages

A page can be rotated clockwise, by 90 degrees, when displayed or printed. The `Page.GetRotation()` method returns the `Page.Rotate` enum specifying the current rotation. Similarly, `Page.SetRotation()` sets the current rotation.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/core/page-manipulation/rotate.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
