Skip to footer content
USING IRONPDF

How to Quickly and Easily Move PDF Pages C#

How to Quickly and Easily Move PDF Pages C#: Image 1 - How to Move PDF Pages C#

Moving PDF pages to a new location within a document, or between two documents, is a common requirement when organizing reports, compiling monthly newsletters, or restructuring document pages for better readability. With IronPDF, this process takes just a few lines of code.

This article walks through the steps to move PDF pages in C#, reorder pages, and move content exactly where it needs to be. Complete with working code examples and output images. IronPDF provides a clean, intuitive API that makes these operations straightforward in any .NET environment.

Whether working with a single PDF file or transferring pages between two PDF files, the PdfDocument class object offers all the methods needed. For readers looking to exchange ideas or learn about product updates, subscribe to our blog for offers directly delivered to your mailbox.

Start your free trial to follow along with these examples.

How Can Pages Be Moved Within a PDF Document?

Moving a page within a PDF document using IronPDF involves a simple three-step process: copy the page, insert it at the target position, then delete the original. The PdfDocument class object provides the CopyPage, InsertPdf, and RemovePage methods to handle these operations efficiently. Any reader familiar with the library will find this workflow intuitive.

The following code demonstrates moving the last page of a PDF file to the beginning:

using IronPdf;
using System;
class Program
{
    static void Main(string[] args)
    {
        // Load the PDF document
        PdfDocument pdf = PdfDocument.FromFile("report.pdf");
        // Get the page index of the last page (zero-based indexing)
        int lastPageIndex = pdf.PageCount - 1;
        // Copy the last page into a new PdfDocument class object
        PdfDocument pageToCopy = pdf.CopyPage(lastPageIndex);
        // Insert the copied page at the beginning (position 0)
        pdf.InsertPdf(pageToCopy, 0);
        // Delete the original page (now at a new location due to insertion)
        pdf.RemovePage(lastPageIndex + 1);
        // Save the rearranged PDF document
        pdf.SaveAs("report-reorganized.pdf");
    }
}
using IronPdf;
using System;
class Program
{
    static void Main(string[] args)
    {
        // Load the PDF document
        PdfDocument pdf = PdfDocument.FromFile("report.pdf");
        // Get the page index of the last page (zero-based indexing)
        int lastPageIndex = pdf.PageCount - 1;
        // Copy the last page into a new PdfDocument class object
        PdfDocument pageToCopy = pdf.CopyPage(lastPageIndex);
        // Insert the copied page at the beginning (position 0)
        pdf.InsertPdf(pageToCopy, 0);
        // Delete the original page (now at a new location due to insertion)
        pdf.RemovePage(lastPageIndex + 1);
        // Save the rearranged PDF document
        pdf.SaveAs("report-reorganized.pdf");
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Rearrange PDF Pages Output

How to Quickly and Easily Move PDF Pages C#: Image 2 - Rearranged PDF with the last page in the input PDF

The code above loads a PDF file, then uses CopyPage to extract the last page by its page index. Since IronPDF uses zero-based page numbering, page number 1 corresponds to index 0. After inserting the page at the start, the original moves down by one position, so the delete operation accounts for this shift. Passing an invalid index throws an exception, so always verify the page count first.

For more details on page manipulation methods, refer to the Add, Copy & Delete PDF Pages guide.

What Is the Process for Moving Several Pages at Once?

When working with multiple pages, the CopyPages method allows extracting several pages simultaneously. This approach is ideal when needing to rearrange pages in bulk—such as moving a range of document pages to the end of a file. The file path string parameter accepts any valid location on the system.

using IronPdf;
using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        // Load the input PDF document
        PdfDocument pdf = PdfDocument.FromFile("quarterly-report.pdf");
        // Copy pages at indexes 1 and 2 (the second and third pages)
        PdfDocument selectedPages = pdf.CopyPages(new List<int> { 1, 2 });
        // Merge the copied pages at the end of the document
        PdfDocument result = PdfDocument.Merge(pdf, selectedPages);
        // Remove the original two pages (now duplicated)
        result.RemovePages(new List<int> { 1, 2 });
        // Save to a new file path
        result.SaveAs("quarterly-report-reordered.pdf");
    }
}
using IronPdf;
using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        // Load the input PDF document
        PdfDocument pdf = PdfDocument.FromFile("quarterly-report.pdf");
        // Copy pages at indexes 1 and 2 (the second and third pages)
        PdfDocument selectedPages = pdf.CopyPages(new List<int> { 1, 2 });
        // Merge the copied pages at the end of the document
        PdfDocument result = PdfDocument.Merge(pdf, selectedPages);
        // Remove the original two pages (now duplicated)
        result.RemovePages(new List<int> { 1, 2 });
        // Save to a new file path
        result.SaveAs("quarterly-report-reordered.pdf");
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Example Output

How to Quickly and Easily Move PDF Pages C#: Image 3 - Image 3 of 4 related to How to Quickly and Easily Move PDF Pages C#

This code copies two pages from the PDF document, uses the Merge method to combine them at the end, then removes the originals to complete the reorder process. The var keyword can also be used for cleaner declarations when preferred.

Learn more about splitting and combining documents in the Merge or Split PDFs tutorial.

How Do I Rearrange Pages Between Two PDF Files?

Transferring pages between two PDF documents is equally straightforward. This is useful when consolidating content from multiple sources—such as moving select pages from one report into another.

using IronPdf;
using System;
class Program
{
    static void Main(string[] args)
    {
        // Load the source PDF file
        PdfDocument sourceDoc = PdfDocument.FromFile("source-document.pdf");
        // Load the destination PDF file
        PdfDocument destinationDoc = PdfDocument.FromFile("destination-document.pdf");
        // Copy page at index 0 from source (first page)
        PdfDocument pageToMove = sourceDoc.CopyPage(0);
        // Insert into destination at position 2 (third page location)
        destinationDoc.InsertPdf(pageToMove, 2);
        // Save the updated destination document (overwrite original)
        destinationDoc.SaveAs("destination-document.pdf");
        // Optionally delete from source and save
        sourceDoc.RemovePage(0);
        sourceDoc.SaveAs("source-document-updated.pdf");
    }
}
using IronPdf;
using System;
class Program
{
    static void Main(string[] args)
    {
        // Load the source PDF file
        PdfDocument sourceDoc = PdfDocument.FromFile("source-document.pdf");
        // Load the destination PDF file
        PdfDocument destinationDoc = PdfDocument.FromFile("destination-document.pdf");
        // Copy page at index 0 from source (first page)
        PdfDocument pageToMove = sourceDoc.CopyPage(0);
        // Insert into destination at position 2 (third page location)
        destinationDoc.InsertPdf(pageToMove, 2);
        // Save the updated destination document (overwrite original)
        destinationDoc.SaveAs("destination-document.pdf");
        // Optionally delete from source and save
        sourceDoc.RemovePage(0);
        sourceDoc.SaveAs("source-document-updated.pdf");
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

PDF Output

How to Quickly and Easily Move PDF Pages C#: Image 4 - Image 4 of 4 related to How to Quickly and Easily Move PDF Pages C#

The example above demonstrates loading two documents, extracting a page from the source using CopyPage, and using InsertPdf to add it at the specified int pageIndex in the destination. Both the source and destination can be saved independently.

What Are Common Use Cases for Reordering PDF Pages?

Developers frequently need to rearrange PDF pages for practical business scenarios:

  • Monthly newsletters: Moving a cover page or table of contents to the front of compiled content
  • Report generation: Inserting a blank page for section breaks or repositioning summary pages
  • Document assembly: Combining pages from multiple sources into a logical order regardless of page width or orientation
  • Archive organization: Extracting and relocating specific pages for reference documents

The PdfDocument class provides features beyond simple page operations. Visit the IronPDF features page to learn about additional capabilities like adding headers, watermarks, and digital signatures.

Conclusion

Being able to rearrange and move PDF pages in C# becomes a simple process with IronPDF's intuitive API. The combination of CopyPage, InsertPdf, and RemovePage methods provides complete control over document pages, whether working within a single PDF or across two documents.

IronPDF works seamlessly in VB.NET as well, offering the same straightforward SDK for .NET developers who prefer that environment. For complete API details, visit the API Reference docs.

Ready to add PDF page manipulation to your project? Or looking to create fresh PDF documents from scratch? Purchase a license or start a free trial to begin building today.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More