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

C# Word - Extract or Copy Pages from Word File in C#.NET

Extract/Copy  Pages of Word Document in C# Project


The Microsoft Office Word, known as Word document, is a widely-used form of file that allows users to open & read documents even though they are using different types of word processors. Besides, the capacity to be locked against editing or processing by others makes Word file become increasingly popular among large enterprises and organizations.

Related .net document control helps:
c# asp.net webforms document viewer: ASP.NET WebForms application document viewer control: view, annotate, redact, convert files online in ASP.NET
asp.net sharepoint pdf editor using c#: ASP.NET SharePoint PDF Editor Control: view, edit, annotate, redact PDF document in SharePoint sites
asp.net pdf viewer using c#: ASP.NET PDF Viewer Control: view, navigate, zoom Adobe PDF document in C# ASP.NET
c# asp.net powerpoint document viewer: ASP.NET PowerPoint Document Viewer Control: view pptx files online in C# using ASP.NET
c# asp.net text document viewer: C# HTML5 Viewer: Load, View, Convert, Annotate and Edit OpenOffice, CSV and Text file
asp.net pdf editor using c#: EdgePDF: ASP.NET PDF Editor Web Control: Online view, annotate, redact, edit, process, convert PDF documents
asp.net open pdf password using c#: ASP.NET PDF Password Edit Control: online add, remove, update PDF file open password using C#

Using this C#.NET Word document page extract library control, developers can extract pages from Word document. Using the library, you should be sure that the page index is valid.

C# DLLs: Extract, Copy and Paste Word Page

Add references:











Use corresponding namespaces;

  using RasterEdge.Imaging.Basic;

  using RasterEdge.XDoc.Word;

Extract Word Pages Using C#

You may extract pages of Word file and save them to a new word file.

DOCXDocument docx = new DOCXDocument(@"C:\1.docx");
int[] pageIndexes = new int[] { 1, 3};
docx.ExtractPages(pageIndexes, @"C:\extract.docx");

Copy Word Pages and Append to Another Word File Using C#

You may copy pages of Word file and paste them to another word file.

DOCXDocument docx = new DOCXDocument(@"C:\1.docx");
int[] pageIndexes = new int[] { 1, 3};
Stream stream = new MemoryStream();
//extract pages to stream
docx.ExtractPages(pageIndexes, stream);
FileStream fileStream = File.Open(@"C:\2.docx", FileMode.Open);
//paste the pages extracted to second word file
DOCXDocument.CombineDocument(new Stream[] { stream, fileStream }, @"C:\copy.docx");