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: Delete Existing PDF Pages
  |  
Home ›› XDoc.PDF ›› C# PDF: Delete PDF Page

How to delete, remove pages from Adobe PDF document in C#.NET


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




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


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.







C# delete a page from pdf file


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




C# delete pages with specified page range from 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




C# delete specified pages from 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




.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 DeletePage(int pageId)

Description:
     Delete specified page from the input PDF file.

Parameters:



public override void DeletePages(int pageId, int pageCount)

Description:
     Delete consecutive pages from the input PDF file starting at specified position.

Parameters:



public void DeletePages(int[] pageIndexes)

Description:
     Delete specified pages from the input PDF file.

Parameters: