How to Start Convert PDF Read PDF Edit PDF PDF Report Builder 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 Page Editor Library
How to delete, remove pages from PDF file using C#.net


Full sample C# source code for deleting pages from Adobe PDF document in C#. Free Online Trial Download







In this C# tutorial, you will learn how to remove PDF document pages programmatically using C#

  • Remove a PDF page, a list of pages
  • Remove a list of specified pages
  • Remove consecutive pages

How to remove PDF pages programmatically using C#

  1. Download XDoc.PDF Pages C# library
  2. Install C# library to remove Adobe PDF pages programmatically
  3. Step by Step Tutorial










  • Best C#.NET PDF Editor Contrl for deleting PDF pages in Visual Studio .NET program
  • Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint
  • Advanced component and library able to delete PDF page in both Visual C# .NET WinForms and ASP.NET WebForms project
  • C# .NET PDF library for .NET Core includes: c# get thumbnail of pdf, how to set pdf page size in c#, c# determine number of pages in pdf, add header and footer in pdf using c#, c# rotate pdf page.
  • Free online C# class source code for deleting specified PDF pages in .NET console application
  • Able to remove a single page or a range of pages from PDF document
  • Ability to remove extra blank pages from PDF files
  • Free trial package for quick integration in .NET as well as compatible with 32 bit and 64 bit windows system


C#.NET PDF document page deleting library control (XDoc.PDF) can be easily integrated into any C#.NET class applications to delete any unnecessary page from target existing PDF document file. Using RasterEdge Visual C# .NET PDF page deletion component, developers can easily select one or more PDF pages and delete it/them in both .NET web and Windows applications.

C#.NET PDF page removing & deleting library control SDK is a mature component on the market, which can also provides other PDF document page processing functions, such as PDF document merging function, PDF page rotating function, PDF page inserting function, PDF page reordering function and PDF document splitting function.

This tutorial offers three pieces of C# sample codes for PDF page(s) deletion. XDoc.PDF enables you to delete PDF page(s) with customized options, including setting a single page, a series of pages, and random pages to be removed from PDF file.







How to remove a page from pdf file in C#


You can easily remove an entire page from a PDF file in C#. Below are the steps and C# sample code to remove a page from PDF using XDoc.PDF for .NET library.

  • Create a PDFDocument object with a PDF file loaded
  • Remove the 3rd page of the PDF document
  • Save the PDF file



        #region delete one page from pdf file
        internal static void deleteOnePageFromPdf()
        {
            String filepath = @"";
            String outPutFilePath = @"";
            PDFDocument doc = new PDFDocument(filepath);

            // Detele page 2 (actually the third page).
            doc.DeletePage(2);

            // Save the file.
            doc.Save(outPutFilePath);
        }
        #endregion




How to delete continuous pages from pdf file using C#


You can also remove a range of pages from PDF file in C#. Below are the steps and C# sample code to remove three continuous pages from PDF document.

  • Create a PDFDocument object with a PDF file loaded
  • Remove a series of 3 pages, starting from the second page
  • Save the PDF file



        #region delete pages with specified page range from pdf file
        internal static void deletePagesWithRangeFromPdf()
        {
            String filepath = @"";
            String outPutFilePath = @"";
            PDFDocument doc = new PDFDocument(filepath);

            // Detele a series of 3 pages, starting from the second page. 
            doc.DeletePages(1, 3);

            // Save the file.
            doc.Save(outPutFilePath);

        }
        #endregion




How to remove discontinuous pages from pdf file in C#


You can also remove a list of discontinuous pages from PDF file in C#. Below are the steps and C# sample code to remove five discontinuous pages from PDF document.

  • Create a PDFDocument object with a PDF file loaded
  • Remove 5 pages from pdf
  • Save the PDF file



        #region delete specified pages from pdf file
        internal static void deleteSpecifiedPagesFromPdf()
        {
            String filepath = @"";
            String outPutFilePath = @"";
            PDFDocument doc = new PDFDocument(filepath);

            // Get PageIndexes.
            int[] detelePageindexes = new int[] { 1, 3, 5, 7, 9 };

            // Delete pages.
            doc.DeletePages(detelePageindexes);

            // Save the file.
            doc.Save(outPutFilePath);
        }
        #endregion




Delete a page in a PDFDocument object at specified position


//  get PDFDocument object from a source file
String inputFilePath = Program.RootPath + "\\" + "1.pdf";
PDFDocument doc = new PDFDocument(inputFilePath);

//  delete the 3rd page
int pageIndex = 2;
doc.DeletePage(pageIndex);

//  save the PDFDocument
String outputFilePath = Program.RootPath + "\\" + "Output.pdf";
doc.Save(outputFilePath);




Delete consecutive pages in a PDFDocument object


//  get PDFDocument object from a source file
String inputFilePath = Program.RootPath + "\\" + "1.pdf";
PDFDocument doc = new PDFDocument(inputFilePath);

//  detele consecutive 3 pages from the 2nd page
int pageIndex = 1;
int pageCount = 3;
doc.DeletePages(pageIndex, pageCount);

//  save the PDFDocument
String outputFilePath = Program.RootPath + "\\" + "Output.pdf";
doc.Save(outputFilePath);




Delete pages in a PDFDocument object


//  get PDFDocument object from a source file
String inputFilePath = Program.RootPath + "\\" + "1.pdf";
PDFDocument doc = new PDFDocument(inputFilePath);

//  delete 5 pages by their page indexes
int[] pageIndexes = new int[] { 1, 3, 5, 7, 9 };
//delete pages
doc.DeletePages(pageIndexes);

//  save the PDFDocument
String outputFilePath = Program.RootPath + "\\" + "Output.pdf";
doc.Save(outputFilePath);