XDoc.PDF
Features
Tech Specs
How-to C#
How-to VB.NET
Pricing
C# PDF: How to PDF Create PDF Export File and Page Process PDF Read PDF Write Form Process Document Protect Annotation & Drawing PDF Print WPF Viewer & Editor Work with Other SDKs Barcode Read Barcode Create OCR Twain
Page: Move Page Position
  |  
Home ›› XDoc.PDF ›› C# PDF: Move PDF Page

How to sort, change Adobe PDF pages order 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




Best Visual Studio .NET PDF file edit SDK for sorting PDF page order in C#.NET class


A C#.NET PDF page reorganizing library control, which is built on .NET framework 2.0+


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


Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:

       

       If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.

       

       If using x86, the platform target should be x86.




        #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 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




.NET Class Namespace Required



In order to run the sample code, the following steps would be necessary.


Add necessary references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XImage.Raster.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XDoc.PDF.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.PDF;





public override void SwapTwoPages(int pageIndex1, int pageIndex2)

Description:
     Swap two specified pages.

Parameters:



public int MovePage(int moveFrom, int moveTo)

Description:
     Swap two specified pages.

Parameters:



public int SortPage(int[] pageOrders)

Description:
     Reorder the PDF pages with specified order.

Parameters: