Rotate, Remove, and Rearrange PDF Pages Easily with WPF PDF Viewer
Tags: csharp, dotnet, productivity
Published: 2020-12-21 11:31:36

---
title: Rotate, Remove, and Rearrange PDF Pages Easily with WPF PDF Viewer
published: true
date: 2020-12-18 11:53:29 UTC
tags: csharp, dotnet, productivity
canonical_url: https://www.syncfusion.com/blogs/post/rotate-remove-and-rearrange-pdf-pages-easily-with-wpf-pdf-viewer.aspx
cover_image: https://www.syncfusion.com/blogs/wp-content/uploads/2020/12/Rotate-Remove-and-Rearrange-PDF-Pages-Easily-with-WPF-PDF-Viewer-1-672x372.png
---

Usually, PDF files created from scanning physical papers will require rotating, rearranging, and the removal of redundant pages. The [Syncfusion WPF PDF Viewer](https://www.syncfusion.com/wpf-ui-controls/pdf-viewer) is a single-stop shop for performing these operations in a PDF document quickly and easily.

The support for multiple-page selection and miniature previews (thumbnails) in the PDF Viewer will help you review, select, and organize the pages in large PDF files in a matter of seconds. In this blog, we will explore how to perform the following operations interactively and with code examples:

- [Rotate pages in a PDF.](#how-to-rotate-pages-in-a-pdf)
- [Remove pages in a PDF.](#how-to-remove-pages-in-a-pdf)
- [Rearrange pages in a PDF.](#how-to-rearrange-pages-in-a-pdf)

## Getting started

First things first:

1. Create a new WPF project and install the PDF Viewer [NuGet package](https://www.nuget.org/packages/Syncfusion.PdfViewer.WPF/).
2. Include the following code in your XAML page to add the PDF Viewer as a child to window.
```html
<Window x:Class="PdfViewer.MainWindow" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:pdfviewer="clr-namespace:Syncfusion.Windows.PdfViewer;assembly=Syncfusion.PdfViewer.WPF"
        Title="PDF Viewer">
    <pdfviewer:PdfViewerControl x:Name="pdfViewer"/>
</Window>
```

## How to rotate pages in a PDF

If you need to rotate pages that are displayed upside down or with incorrect orientation, you can do this in the PDF Viewer:

1. Open the PDF file in PDF Viewer using the open button.
2. Click the **organize pages icon   ![organize pages icon](https://www.syncfusion.com/blogs/wp-content/uploads/2020/12/organize-pages-icon.png) **in the left toolbar to display the thumbnails of PDF pages.
3. Select the page you want to rotate. To select multiple pages, hold down the **Ctrl** key and click them all.
4. Click the **counterclockwise icon   ![counterclockwise icon](https://www.syncfusion.com/blogs/wp-content/uploads/2020/12/counterclockwise-icon.png) **or **clockwise** **icon  ![clockwise icon](https://www.syncfusion.com/blogs/wp-content/uploads/2020/12/clockwise-icon.png) ** in the toolbar to rotate the selected pages 90 degrees with respect to the current page position.
5. After performing the operation, close the organizing pages view.

![Rotating pages of a PDF](https://www.syncfusion.com/blogs/wp-content/uploads/2020/12/Rotating-pages-of-a-PDF.gif)<figcaption>Rotating pages of a PDF</figcaption>

You can also rotate the pages from the application level using the built-in APIs. The following code example elaborates on how to rotate specific PDF pages to a specific angle and direction.

**To rotate the pages to a specific angle**

```csharp
private void RotatePages()
{
   int[] pageIndexes = new int[] { 0, 2, 6 };
   // Rotates the PDF pages 90 degrees regardless of its current rotation angle. 
   pdfViewer.PageOrganizer.Rotate(pageIndexes, PdfPageRotateAngle.RotateAngle90);
}
```

**To rotate specific pages clockwise**

```csharp
private void RotatePagesClockwise()
{
    int[] pageIndexes = new int[] { 0, 2, 6 };
    // Rotates the PDF pages 90 degrees clockwise with respect to the current rotation angle.
    pdfViewer.PageOrganizer.RotateClockwise(pageIndexes);
}
```

**To rotate specific pages counterclockwise**

```csharp
private void RotatePagesCounterclockwise()
{
    int[] pageIndexes = new int[] { 0, 2, 6 };
    // Rotates the PDF pages to 90 degrees in counterclockwise direction with respect to the current rotation angle.
    pdfViewer.PageOrganizer.RotateCounterclockwise(pageIndexes);
}
```

**Note:** You can rotate PDF pages 90, 180, 270, and 360 degrees only.

## How to remove pages in a PDF

To remove pages in a PDF document, follow these steps:

1. Open the input PDF file in PDF Viewer.
2. Click the **organize pages icon ![organize pages icon](https://www.syncfusion.com/blogs/wp-content/uploads/2020/12/organize-pages-icon-1.png) **in the left toolbar to display the thumbnails of the PDF pages.
3. Select the page you want to remove. To select multiple pages, hold down the **Ctrl** key and select them all.
4. Click the **delete icon  ![Delete icon](https://www.syncfusion.com/blogs/wp-content/uploads/2020/12/delete-icon.png)  **in the toolbar to remove the selected pages.
5. Once the operation is performed, close the organizing pages view.

![Remove pages in a PDF](https://www.syncfusion.com/blogs/wp-content/uploads/2020/12/Remove-pages-in-a-PDF.gif)<figcaption>Remove pages in a PDF</figcaption>

You can also remove pages at the application level using the built-in APIs. The following code example elaborates on how to remove specific pages in a PDF file.

**To remove a page at a specific index**

```csharp
private void RemovePage()
{
   // Removes a page at a specific index.
   pdfViewer.PageOrganizer.RemoveAt(2);
}
```

**To remove specific pages**

```csharp
private void RemovePages()
{
   int[] pageIndexes = new int[] { 0, 2, 6 };
   // Removes specific pages in a PDF file.
   pdfViewer.PageOrganizer.RemovePages(pageIndexes);
}
```

**Note:** You cannot remove all the pages in a PDF file. You need to retain at least one page.

## How to rearrange pages in a PDF

To rearrange the pages in a PDF document, follow these steps:

1. Open the PDF file in PDF Viewer.
2. Click the **organize pages icon  ![organize pages icon](https://www.syncfusion.com/blogs/wp-content/uploads/2020/12/organize-pages-icon-2.png) **in the left toolbar to display the thumbnails of the PDF pages.
3. Select the page you want to reorder. To select multiple pages, hold down the **Ctrl** key and select them all.
4. Drag the selected pages to the location to which you need to move them. This will rearrange the pages automatically.
5. Once you’ve performed the operation, close the organizing pages view for further processing.

![Rearrange pages in a PDF](https://www.syncfusion.com/blogs/wp-content/uploads/2020/12/Rearrange-pages-in-a-PDF.gif)<figcaption>Rearrange pages in a PDF</figcaption>

You can also rearrange the pages at the application level using the built-in APIs. The following code example elaborates on how to rearrange the pages in a PDF file with the expected page order.

```csharp
private void RearrangePages()
{
    int[] expectedOrder = new int[] { 1, 0, 2 };
    // Rearranges the pages in a PDF file with 3 pages in the expected order.
    pdfViewer.PageOrganizer.ReArrange(expectedOrder);
}
```

**Note:** The length of the expected order should be equal to the original page count.

## Resources

You can download the samples from the following GitHub repositories:

- [Organize pages interactively](https://github.com/SyncfusionExamples/WPF-PDFViewer-Examples/tree/master/DisplayPDF)
- [Organize pages using code API](https://github.com/SyncfusionExamples/WPF-PDFViewer-Examples/tree/master/OrganzingPages-Examples/)

## Conclusion

Thank you for reading this blog. I hope that this information helps you organize your PDF file into a professional-looking document. You can find demos of other [PDF Viewer](https://www.syncfusion.com/wpf-ui-controls/pdf-viewer) features in this [GitHub repository](https://github.com/syncfusion/wpf-demos/tree/master/pdfviewer).

Feel free to share your feedback or questions in the comments section below. You can also contact us through our [support forums](https://www.syncfusion.com/forums), [Direct-Trac](https://www.syncfusion.com/account/login), or [feedback portal](https://www.syncfusion.com/feedback/). We are always happy to assist you!

## See also

[Blog] [Top 10 Features of Syncfusion WPF PDF Viewer](https://dev.to/vijays/top-10-features-of-syncfusion-wpf-pdf-viewer-5c9g-temp-slug-4530042)

[Blog] [Problems Applying Right-to-Left Rendering in WPF PDF Viewer?](https://dev.to/syncfusion/problems-applying-right-to-left-rendering-in-wpf-pdf-viewer-2pmm)

[Blog] [PDF to Image Conversion is Made Easy with WPF PDF Viewer](https://dev.to/karthickramasamy08/pdf-to-image-conversion-is-made-easy-with-wpf-pdf-viewer-36fo-temp-slug-4978779)

[Blog] [Inking PDF Documents with Essential PDF Viewer](https://www.syncfusion.com/blogs/post/inking-pdf-documents-with-essential-pdf-viewer.aspx)