XDoc.Word
Features
Tech Specs
How-to C#
Pricing

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


Provides Users with Mature Document Manipulating Function for Deleting Word Pages





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.

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.


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