We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Split Ms Word Multi Page Document into Separate Files (10 Page Document into 10 files - 1 Page each)

Dears, How can we Split Ms Word Multi Page (having Headers & Footers) Document into Separate Files (10 Page Document into 10 files - 1 Page each).Thanks,

1 Reply

SY Sethumanikkam Yogendran Syncfusion Team July 27, 2017 01:15 PM UTC

Hi Nilofer,

Thank you for contacting Syncfusion support.

The Word document is a flow document in which contents will not be preserved page by page; instead the contents will be preserved sequentially section by section. Each section may extend to various pages based on its contents like table, text, images etc..

Please refer the below KB article which explains the same:
http://www.syncfusion.com/kb/3989/why-it-is-not-possible-to-access-the-word-document-contents-page-by-page

Hence it is not directly possible to access the Word document contents page by page, the same holds in Essential DocIO. As a workaround, you can split the contents of each page as separate section in the input Word document and using DocIO can split into multiple files by sections instead of pages.

Please refer the below code snippet with attached template, and let us know if this helps you.
 
// Loads an existing input document.
WordDocument mainDocument = new WordDocument("Template.docx");
// Iterates each section from main document.
foreach (WSection section in mainDocument.Sections)

{
    // Creates new Word document.
    WordDocument currDocument = new WordDocument();
    // Clones section to current document.
    currDocument.Sections.Add(section.Clone());
    // Saves Word document and closes the WordDocument instance.
    currDocument.Save("Template_" + mainDocument.ChildEntities.IndexOf(section) + ".docx");
    currDocument.Close();
}
mainDocument.Close();
 

Please let us know if you have any other questions.

Regards,
Sethumanikkam.Y


Loader.
Live Chat Icon For mobile
Up arrow icon