C#: Online Guide
How To: Word SDK
Page: Delete Word Pages
Page: Delete Word Pages
  |  
Home ›› XDoc.Word ›› C# Word: Delete Word Pages

C# Word - Delete Word Document Page in C#.NET


Provides Users with Mature Document Manipulating Function for Deleting Word Pages




Overview



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


Related .net document control helps:
asp.net office viewer: ASP.NET Office Word Document Viewer: view Word doc files online using C# in ASP.NET MVC web applications
document viewer asp.net c#: ASP.NET Document Viewer using C#: Open, View, Annotate, Redact, Convert document files in ASP.NET using C#, HTML5, JQuer...
asp.net document viewer example: EdgeDoc:ASP.NET Document Viewer C# Control: Open, view, annotate, redact, convert documents online in C#, VB.NET, AS...
asp.net edit pdf page control: ASP.NET PDF Pages Edit Control: add, remove, sort, replace PDF pages online using C#
asp.net view excel in browser: ASP.NET Excel Viewer in C# Control (MVC & WebForms): view Office Excel document in web browser.
asp.net mvc image viewer: ASP.NET Image Viewer Control(MVC & WebForms): view, annotate, redact, convert image files in html, JQuery
asp.net sharepoint document viewer control: ASP.NET SharePoint Document Viewer: view, annotate, redact documents in SharePoint


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


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




C# DLLs: Delete Word Page



Add references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.XDoc.Office.Inner.Common.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XDoc.Office.Inner.Office03.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.XDoc.Word.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XImage.Raster.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.Word;




Delete a Single Word Page from Word File in C#



How to delete a single page from a Word document.




String filepath = @"";
String outPutFilePath = @"";
DOCXDocument doc = new DOCXDocument(filepath);

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

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





Delete Consecutive Pages from Word in C#



How to delete a range of pages from a Word document.




String filepath = @"";
String outPutFilePath = @"";
DOCXDocument doc = new DOCXDocument(filepath);

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

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





Delete Specified Pages from Word in C#



How to delete several defined pages from a Word document.




String filepath = @"";
String outPutFilePath = @"";
DOCXDocument doc = new DOCXDocument(filepath);

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

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

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