ByteScout PDF SDK - C# - Reorder Pages - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout PDF SDK – C# – Reorder Pages

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF SDK – C# – Reorder Pages

ByteScout PDF SDK – C# – Reorder Pages

Program.cs

using Bytescout.PDF;
using System;
using System.Diagnostics;

namespace RemovePdfProtection
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                using (Document doc = new Document())
                {
                    doc.Load("sample.pdf");

                    // Swap first and second pages:
                    Page tmp = doc.Pages[1];
                    doc.Pages.Remove(1);
                    doc.Pages.Insert(0, tmp);

                    //Save output file
                    doc.Save("result.pdf");
                }

                // Open result document in default associated application (for demo purpose)
                ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf");
                processStartInfo.UseShellExecute = true;
                Process.Start(processStartInfo);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadLine();
        }
    }
}

  Click here to get your Free Trial version of the SDK

Tutorials:

prev
next