We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Saving Doc/Docx with aspose.words 14.12.0 slower

We have been using aspose.words from dec 2013 for a while. we want to upgrade to the latest version but there seems to be a performance issue in saving to a memorystream.



using the code below, the line that saves the output to the memorystream takes around 1 second or less in the older version. in this 14.12.0 version, it takes around 4 seconds. The sample file I am using is only 524k for doc and 158k for docx, so I wouldn’t expect it to be taking this long. can you try and reproduce and let me know if you are seeing the same thing. I don’t know if this is an issue with this version of aspose.words or maybe its been slower for a while.



public byte[] Build(byte[] inputFile, KeyValuePair[] mergeFields, byte[] logoFile, decimal top, decimal left)

{

using (var output = new MemoryStream())

{



var document = _dal.Open(inputFile);



foreach (KeyValuePair item in mergeFields)

{

var merField = String.Format("[{0}]", item.Key);

_dal.Replace(document, merField, item.Value);

}



if (logoFile != null)

{

_dal.InsertLogo(document, logoFile, left, top);

}



document.Save(output, SaveFormat.Docx);



return output.ToArray();

}

}





for the purposes of a test, just create some code that will open and save the document to a stream. I just realized this code snippet doesn’t include everything.



Hi Kirk,

Thanks for your inquiry. I have tested the scenario (open and save the document) using latest version of Aspose.Words for .NET 14.12.0 and have not found the shared issue.

It would be great if you please share a standalone/runnable simple application (for example a Console
Application Project
) that demonstrates the code (Aspose.Words code) you used to generate
your output document. I will investigate the issue on my side and provide you more information.

attached is my test harness. just run it and choose the filetype and select the doc or docx from the first posting. I have had a wide range of times anywhere from 4-5 seconds up to 12 seconds. especially seems slow the first time, but then maybe a little faster after that.



in my opinion both these files are small enough that it shouldn’t be taking more than 1-2 seconds to open and save them. that’s about all im doing in this code. we are currently using 13.11.0 of words in production and that only takes 1-2 seconds. seems like when I debugged this, all the time was spent just on the open and the save methods.

Hi Kirk,

Thanks for sharing the detail. I have tested the scenario at Windows 7 (64 bit) using the shared code and have not found the performance issue. Please check the attached image for detail.

Could you please share following detail for further investigation?

What environment are you running on?

  • OS (Windows Version)
  • Architecture (32 / 64 bit)
  • .NET Framework version

windows7 64bit
.net 4.5
16gb memory
SSD drive

ok that’s very strange then. how is it possible that it runs in under a second for you and so slowly for me. the shortest time I saw was 3-4 seconds. hmm…

Hi Kirk,

Thanks
for sharing the detail. I have tested again the same scenario at Windows 7 (64 bit), .NET Framework 4.5 with shared application. The total execution time is around .4 second.

Please make sure that you are using the same document shared in this forum thread. Could you please create a separate console application for Word documents which uses only Aspose.Words and test the same scenario? If you still face the same issue, please share that application here for further investigations.