Aspose.Words.Document.Save is slower than expected

Hi

We have some fairly simple code which joins (configurable) multiple document sections together and then produces a final resulting document via the Document.Save method…

Document docDest = compiledDocumentList[0].Clone();
docDest.Sections.Clear();

for (int docIndex = 0; docIndex < compiledDocumentList.Count; ++docIndex)
{
    Document docItem = compiledDocumentList[docIndex].Clone();
    docItem.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;
    foreach (Section srcSection in docItem)
    {
        Section newSection = (Section)docDest.ImportNode(srcSection, true, ImportFormatMode.KeepSourceFormatting);
        docDest.Sections.Add(newSection);
    }
}

using (MemoryStream msJoined = new MemoryStream())
{
    docDest.Save(msJoined, SaveFormat.Doc);
}

This code does work, but my issue is with the length of time spent inside the .Save method at the end. I’ve optimised the code as much as possible and even when piecing together 10 different sections, all of the preceding operations are sub-second until the process gets to the .Save line. We’re observing the time spent in this area of code to be between 5 and 10 seconds depending on the number of sections being joined together. This length of time spent just to save the content out to a memory stream isn’t acceptable in a scenario where we would be producing hundreds or thousands of letters in a production run so needs to be made quicker.

Can you indicate if there is anything obviously wrong with the above code in terms of implementation of Aspose.Words, if the Document.Save code can be made quicker somehow (save options, property changes?), or if there is literally nothing that can be done to make that method call run quicker.

Thanks
Gordon

@gordonNPS,

Please ZIP and attach both Word documents you are getting this problem with here for testing. We will investigate the issue on our end and will provide you more information.