How to Start Tutorials Troubleshooting Main Operations Convert PDF Read PDF Edit PDF PDF Report Generator Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

C# PDF Pages Library
How to sort, renumber Adobe PDF pages using XDoc.PDF for .NET library in C#, ASP.NET, Winforms, WPF, Azure


Support Customizing Page Order of PDF Document in Vusial C#.NET Project





In this tutorial, you learn how to sort, re-order PDF pages' position in the C# ASP.NET Web, Windows applications.

  • Move one PDF page to a new postions
  • Swap two pages' postions
  • Sort list of pages with a certain order

How to sort, order PDF pages using C#

  1. Download XDoc.PDF Document Manager C# library
  2. Install C# library to re-locate PDF pages' positions
  3. Step by Step Tutorial


























  • Best Visual Studio .NET PDF file edit SDK for sorting PDF page order in C#.NET class
  • C# PDF page library includes not only re-number PDF pages, but also c# get pdf page size, how to remove pages from pdf in c#, get pdf page count c#, c# pdf add new page, c# extract pdf page as image, how to add header and footer in pdf using c#.
  • A C#.NET PDF page reorganizing library control, which is built on .NET standard 2.0 and framwork 4.x
  • Free .NET component and library for moving PDF pages position in both .NET WinForms and ASP.NET project
  • Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint
  • Free online C# code solutions for sorting PDF page order in multiple ways in .NET console program
  • Able to adjust and change selected PDF document page
  • Enable C# users to move, sort and reorder all PDF page in preview
  • Support to reverse page order in PDF document


RasterEdge C#.NET PDF document page reordering control SDK (XDoc.PDF) is a thread-safe .NET library that can be used to adjust the PDF document pages order. This PDF document page reorganizing control condenses quick PDF page sorting functions into a compact library, which is compatible with .NET-compliant programming language C#.

Using this C#.NET PDF document page reorganizing library control, developers can swap or adjust the order of all or several PDF document pages, or just change the position of certain one PDF page in an extremely easy and quick way using C# code.

Besides C#.NET PDF document page sorting function, RasterEdge has also offered other .NET PDF page processing functions, like PDF documents merging, PDF page rotating, PDF image extracting, PDF page inserting, PDF page deleting and PDF document splitting.





C# move pdf page to the specified position


        #region move pdf page to the specified position
        internal static void movePageToSpecifiedPosition()
        {
            String inputFilePath = @"C:\1.pdf";
            String outputFilePath = @"C:\Output.pdf";

            //  load the PDF file
            PDFDocument doc = new PDFDocument(inputFilePath);

            //  move the 2nd page in the file
            int moveFrom = 1;
            //  to the 6th position in the file
            int moveTo = 5;
            //  move the page 
            doc.MovePage(moveFrom, moveTo);

            //  output the document
            doc.Save(outputFilePath);

        }
        #endregion




C# swap two pdf pages positions


        #region swap two pdf positions
        internal static void swapTwoPages()
        {
            String filepath = @"";
            String outPutFilePath = @"";
            PDFDocument doc = new PDFDocument(filepath);

            // Swap page 0 and page 1.
            doc.SwapTwoPages(0, 1);
        }
        #endregion




C# Sort Multiple PDF Pages with a Certain Order


        #region Sort Multiple PDF Pages with a Certain Order
        internal static void sortPagesWithSpecifiedOrder()
        {
            //  get PDFDocument object from a source file
            String inputFilePath = @"C:\1.pdf";
            PDFDocument doc = new PDFDocument(inputFilePath);

            //  show page count of the document
            int pageCount = doc.GetPageCount();
            Console.WriteLine("Page Count: " + pageCount);

            //  define the new order for all pages
            //  1. the length of the array MUST BE equal to pageCount
            //  2. each page index SHOULD be in the array and only once
            //  otherwise, the method would throw exception
            int[] pageOrders = new int[] { 1, 3, 0, 5, 4, 6, 2 };
            doc.SortPage(pageOrders);

            //  save the PDFDocument
            String outputFilePath = @"C:\Output.pdf";
            doc.Save(outputFilePath);

        }
        #endregion