I have taken 2 console applications, 1 is using .net core(3.1) and 1 is using .net framework(4.7.2)
I have installed NuGet package on both applications
I have taken some files which are in equal sizes 2.89 MB
I have used below code to convert from docx to pdf in both core and .Net framework
- Code: Select all
static void Main(string[] args)
{
var st = Stopwatch.StartNew();
Console.WriteLine("\n Process Started" + st.Elapsed.ToString());
var floderpath = @"C:\Users\testuser1\Desktop\Agenda Docs\New folder";
var pdfpath = @"C:\Users\testuser1\Desktop\Agenda Docs\New folder\pdf";
var files = Directory.GetFiles(floderpath).ToList();
files.ForEach((file) =>
{
using (Document document = new Document(@file, Spire.Doc.FileFormat.Docx, Spire.Doc.Documents.XHTMLValidationType.None) { TrackChanges = false })
{
var filename = Path.GetFileNameWithoutExtension(file);
var st2 = Stopwatch.StartNew();
Console.WriteLine($"\n File Name: \t{ filename}\t\t{ st2.Elapsed.ToString()} \t Started \t Source File \t {Path.GetFileName(file)}");
document.SaveToFile($"{pdfpath}\\{filename}.pdf", Spire.Doc.FileFormat.PDF);
st2.Stop();
Console.WriteLine($"\n File Name: \t{ filename}\t\t{ st2.Elapsed.ToString()} \t Eneded");
}
});
st.Stop();
Console.WriteLine($"\n Completed All files \t{st.Elapsed.ToString()}");
Console.ReadLine();
}
While running the test, I can convert the file to pdf in 4.5 sec in .Net framework on average. Please see the below screen shot. While I am using same thing on .net core, it is taking 14.5 sec on average. It means the conversion time change is 10 sec. I have tested in different machines as well; however, it is showing the difference of 10 sec.
Test results on.Net framework
Test results on.Net core
Can you please give us some solution for this ?