our client complains about performance when merging with compute. In the previous version they used it took 1-2 seconds per document, now it's 5-6 seconds. Usually they send several hundreds, even thousands of letters, which we prepare in advance (merge). In these cases, time is too much.
Here is my code:
- Code: Select all
using (var document = new Document())
{
document.LoadFromFile(template);
document.SetCustomFontsFolders(Environment.GetFolderPath(Environment.SpecialFolder.Fonts));
document.MailMerge.ClearFields = true;
var resultFile = Path.GetTempFileName() + ".docx";
document.MailMerge.Execute(dr);
document.IsUpdateFields = true;
document.ViewSetup.DocumentViewType = DocumentViewType.PrintLayout;
var sw = new Stopwatch();
sw.Start();
document.SaveToFile(resultFile);
Console.WriteLine(sw.ElapsedMilliseconds);
Process.Start(resultFile);
}
The most time consuming operation is SaveToFile.
My investigation shows that the performance issues were introduced in 7.9.0. In the previous version (7.8.4) the operation took ~1 second, starting from 7.9.0 it takes 5-6 seconds.
Regards