C#: Online Guide
How To: Word SDK
File: Split Word Document
File: Split Word Document
Home ›› XDoc.Word ›› C# Word: Split Word Document

C# Word - Split Word Document in C#.NET

Explain How to Split Word Document in Visual C#.NET Application


C# Word document splitting library control, XDoc.Word, provides an advanced C# programming way to split Word document into smaller Word files in .NET developing applications. Using this C#.NET Word document splitting library control, C# developers can easily and accurately disassemble multi-page Word document into two or more separate Word document files by page(s).

Related .net document control helps:
c# asp.net tiff document viewer: ASP.NET Tiff Document Viewer: view, annotate Tiff files in HTML using C# Control
asp.net azure pdf editor using c#: ASP.NET Azure PDF Editor Control: view, edit, annotate, redact PDF files online
asp.net pdf editor using c#: EdgePDF: ASP.NET PDF Editor Web Control: Online view, annotate, redact, edit, process, convert PDF documents
asp.net annotate pdf using c#: ASP.NET Annotate PDF Control: annotate, comment, markup PDF document online using ASP.NET C#
asp.net pdf viewer using c#: ASP.NET PDF Viewer Control: view, navigate, zoom Adobe PDF document in C# ASP.NET
c# asp.net mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects
c# asp.net azure document viewer: ASP.NET Azure Document Viewer: view, annotate files online using ASP.NET Cloud Service

RasterEdge Visual C# .NET Word document splitter control toolkit SDK can not only offer C# developers a professional .NET solution to split Word document file but also provide them the ability to name outputted Word document files with a customized name pattern using a few lines of simple Visual C# code.

This C#.NET Word document splitting library control offers developers an efficient Word document splitting approach, using which C# developers can split target Word document file by specifying a page or pages. If needed, developers can also combine generated split Word document files with other Word files to form a new Word file using RasterEdge XDoc.Word. Besides, in the process of splitting Word document, developers can also remove certain Word page from target Word file using C#.NET Word page deletion API.

Please note, Word file will be divided from the previous page of your defined page number which starts from 0. For example, your original Word file contains 4 pages. If your page number is set as 1, then the two output Word files will contains the first page and the later three pages respectively.

C# DLLs: Split Word File

Add references:










Use corresponding namespaces;

  using RasterEdge.Imaging.Basic;

  using RasterEdge.XDoc.Word;

Split Word file into two files in C#

This is an C# example of splitting a Word file into multiple ones by number of pages.

String inputFilePath = Program.RootPath + "\\" + "1.docx";
String outputFilePath1 = Program.RootPath + "\\" + "Split1.docx";
String outputFilePath2 = Program.RootPath + "\\" + "Split2.docx";
String[] outputOps = new  String[] { outputFilePath1, outputFilePath2 };
//  split a Word file with options
DOCXDocument.SplitDocument(inputFilePath, 2, outputOps);

Split Word Document into Multiple Word Files in C#

You can use the following C# demo to split Word document to four files.

String inputFilePath = Program.RootPath + "\\" + "1.docx";
String outputFileName = "Output.docx";
int[] splitIndex = new int[3] { 1, 3, 5 }; // Valid value for each index: 1 to (Page Count - 1).

// Create output Word file path list
List<String> outputFilePaths = new List<String>();
for (int i = 0; i <= splitIndex.Length; i++)
        outputFilePaths.Add(Program.RootPath + "\\" + outputFileName + "_" + i.ToString() + ".docx");

// Split input Word file to 4 files:
// File 0: page 0.
// File 1: page 1 ~ 2.
// File 2: page 3 ~ 4.
// File 3: page 5 ~ the last page.
DOCXDocument.SplitDocument(inputFilePath, splitIndex, outputFilePaths.ToArray());