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

C# Word Library
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.

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.


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