How to split a word document into multiple word document?

1 page from the original document = 1 new document.

Since Aspose.Words.Viewer is able to make an image of a specified page, I will don’t understand why we can’t extract a specific page and make another word file with it.

Thanks

Hi

Thanks for your inquiry. Unfortunately there is no way to detect when pages starts and ends. Aspose.Words document represents content and formatting of a document, not its layout into lines and pages.

You can split your document so 1 section from original document = 1 new document. For example see the following code:

//Open document
Document doc = new Document(@"Test115\in.doc");
int index = 0;

//Split document while there is more than one section
while (doc.Sections.Count > 1)
{
    //Create new document
    Document tmp = new Document();
    //Remove first section of this document
    tmp.FirstSection.Remove();
    //Import first section of source document
    Node dstSection = tmp.ImportNode(doc.FirstSection, true, ImportFormatMode.KeepSourceFormatting);
    //Insert section into the temporary document
    tmp.Sections.Add(dstSection);
    //Save temporary document
    tmp.Save(string.Format(@"Test115\out_{0}.doc", index));
    index++;
    //Remove first section from source document
    doc.FirstSection.Remove();
}
//Save the last part of src document
doc.Save(string.Format(@"Test115\out_{0}.doc", index));

Best regards.

But how does Aspose.Words.Viewer do for convert a specified page into an image ?

Hi

Thanks for your inquiry. Aspose.Words.Viewer namespace is currently in beta and limited technical support is provided for it. Please see FAQ for more information.

Best regards.

Well i am not asking for support about Aspose.Words.Viewer. I just asking why something that Aspose.Words.Viewer is able to do (it can get a specific page) is not able directly with Aspose.Words.

Thanks

Hi

Yes, I understand you. I just said that Aspose.Words.Viewer is in beta. We currently work on this feature. MS Word documents do not contain information about lines and pages layout of the document. MS Word renders document into lines and pages on fly. So we should create our own rendering engine.

Aspose.Words.Viewer was included into the Aspose.Words only as demo.

Best regards.

Ok thanks