From d63f55ca80ae9fe61af1049a33d08afbbe94bd3e Mon Sep 17 00:00:00 2001 From: Kathiresan4347 <159137198+Kathiresan4347@users.noreply.github.com> Date: Tue, 10 Feb 2026 17:07:09 +0530 Subject: [PATCH 1/2] 1006383-Modified the sample --- .../Fallback-Font/Fallback-Font/Program.cs | 26 ++++++++------ .../Font-Substitution/Program.cs | 34 +++++++++++-------- .../Use-embedded-Word-fonts/Program.cs | 24 +++++++------ .../Use-embeded-word-font/Program.cs | 2 -- .../Word-document-to-image/Program.cs | 27 +++++++++------ 5 files changed, 63 insertions(+), 50 deletions(-) diff --git a/Performance-metrices/Fallback-Font-Image/.NET/Fallback-Font/Fallback-Font/Program.cs b/Performance-metrices/Fallback-Font-Image/.NET/Fallback-Font/Fallback-Font/Program.cs index f65d7f95..3be94ccf 100644 --- a/Performance-metrices/Fallback-Font-Image/.NET/Fallback-Font/Fallback-Font/Program.cs +++ b/Performance-metrices/Fallback-Font-Image/.NET/Fallback-Font/Fallback-Font/Program.cs @@ -13,19 +13,23 @@ static void Main() using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { // Open an existing Word document - WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx); - //Initialize the default fallback fonts collection. - document.FontSettings.FallbackFonts.InitializeDefault(); - DocIORenderer renderer = new DocIORenderer(); - //Convert the entire Word document to images. - Stream[] imageStreams = document.RenderAsImages(); - for (int i = 0; i < imageStreams.Length; i++) + using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx)) { - //Save the image stream as file. - string imagePath = Path.Combine(Path.GetFullPath(@"Output/Images"), $"WordToImage_{i + 1}.jpg"); - using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write)) + //Initialize the default fallback fonts collection. + document.FontSettings.FallbackFonts.InitializeDefault(); + using (DocIORenderer renderer = new DocIORenderer()) { - imageStreams[i].CopyTo(fileStreamOutput); + //Convert the entire Word document to images. + Stream[] imageStreams = document.RenderAsImages(); + for (int i = 0; i < imageStreams.Length; i++) + { + //Save the image stream as file. + string imagePath = Path.Combine(Path.GetFullPath(@"Output/Images"), $"WordToImage_{i + 1}.jpg"); + using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write)) + { + imageStreams[i].CopyTo(fileStreamOutput); + } + } } } stopwatch.Stop(); diff --git a/Performance-metrices/Font-Substitution-Image/.NET/Font-Substitution/Font-Substitution/Program.cs b/Performance-metrices/Font-Substitution-Image/.NET/Font-Substitution/Font-Substitution/Program.cs index 532004ff..17f3cd3d 100644 --- a/Performance-metrices/Font-Substitution-Image/.NET/Font-Substitution/Font-Substitution/Program.cs +++ b/Performance-metrices/Font-Substitution-Image/.NET/Font-Substitution/Font-Substitution/Program.cs @@ -13,23 +13,27 @@ static void Main() using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { // Open an existing Word document - WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx); - //Hooks the font substitution event - document.FontSettings.SubstituteFont += FontSettings_SubstituteFont; - DocIORenderer renderer = new DocIORenderer(); - //Convert the entire Word document to images. - Stream[] imageStreams = document.RenderAsImages(); - //Unhooks the font substitution event after converting to PDF - document.FontSettings.SubstituteFont -= FontSettings_SubstituteFont; - for (int i = 0; i < imageStreams.Length; i++) + using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx)) { - //Save the image stream as file. - string imagePath = Path.Combine(Path.GetFullPath(@"Output/Images"), $"WordToImage_{i + 1}.jpg"); - using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write)) + //Hooks the font substitution event + document.FontSettings.SubstituteFont += FontSettings_SubstituteFont; + using (DocIORenderer renderer = new DocIORenderer()) { - imageStreams[i].CopyTo(fileStreamOutput); - } - } + //Convert the entire Word document to images. + Stream[] imageStreams = document.RenderAsImages(); + //Unhooks the font substitution event after converting to PDF + document.FontSettings.SubstituteFont -= FontSettings_SubstituteFont; + for (int i = 0; i < imageStreams.Length; i++) + { + //Save the image stream as file. + string imagePath = Path.Combine(Path.GetFullPath(@"Output/Images"), $"WordToImage_{i + 1}.jpg"); + using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write)) + { + imageStreams[i].CopyTo(fileStreamOutput); + } + } + } + } stopwatch.Stop(); Console.WriteLine($"Word To Image processed in {stopwatch.Elapsed.TotalSeconds} seconds"); } diff --git a/Performance-metrices/Use-embedded-Word-fonts-image/.NET/Use-embedded-Word-fonts/Use-embedded-Word-fonts/Program.cs b/Performance-metrices/Use-embedded-Word-fonts-image/.NET/Use-embedded-Word-fonts/Use-embedded-Word-fonts/Program.cs index 9c31ae1e..5ba93774 100644 --- a/Performance-metrices/Use-embedded-Word-fonts-image/.NET/Use-embedded-Word-fonts/Use-embedded-Word-fonts/Program.cs +++ b/Performance-metrices/Use-embedded-Word-fonts-image/.NET/Use-embedded-Word-fonts/Use-embedded-Word-fonts/Program.cs @@ -14,19 +14,21 @@ static void Main() using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { // Open an existing Word document - WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx); - DocIORenderer renderer = new DocIORenderer(); - //Sets true to embed fonts True - renderer.Settings.EmbedFonts = true; - //Convert the entire Word document to images. - Stream[] imageStreams = document.RenderAsImages(); - for (int i = 0; i < imageStreams.Length; i++) + using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx)) { - //Save the image stream as file. - string imagePath = Path.Combine(Path.GetFullPath(@"Output/Images"), $"WordToImage_{i + 1}.jpg"); - using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write)) + using (DocIORenderer renderer = new DocIORenderer()) { - imageStreams[i].CopyTo(fileStreamOutput); + //Convert the entire Word document to images. + Stream[] imageStreams = document.RenderAsImages(); + for (int i = 0; i < imageStreams.Length; i++) + { + //Save the image stream as file. + string imagePath = Path.Combine(Path.GetFullPath(@"Output/Images"), $"WordToImage_{i + 1}.jpg"); + using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write)) + { + imageStreams[i].CopyTo(fileStreamOutput); + } + } } } stopwatch.Stop(); diff --git a/Performance-metrices/Use-embeded-word-font-PDF/.NET/Use-embeded-word-font/Use-embeded-word-font/Program.cs b/Performance-metrices/Use-embeded-word-font-PDF/.NET/Use-embeded-word-font/Use-embeded-word-font/Program.cs index 13efa3e9..cffa1ece 100644 --- a/Performance-metrices/Use-embeded-word-font-PDF/.NET/Use-embeded-word-font/Use-embeded-word-font/Program.cs +++ b/Performance-metrices/Use-embeded-word-font-PDF/.NET/Use-embeded-word-font/Use-embeded-word-font/Program.cs @@ -19,8 +19,6 @@ static void Main() //Creates an instance of DocIORenderer. using (DocIORenderer renderer = new DocIORenderer()) { - //Sets true to embed fonts True - renderer.Settings.EmbedFonts = true; //Converts Word document into PDF document. using (PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument)) { diff --git a/Performance-metrices/Word-to-Image/.NET/Word-document-to-image/Word-document-to-image/Program.cs b/Performance-metrices/Word-to-Image/.NET/Word-document-to-image/Word-document-to-image/Program.cs index eb8c1527..b8a5a107 100644 --- a/Performance-metrices/Word-to-Image/.NET/Word-document-to-image/Word-document-to-image/Program.cs +++ b/Performance-metrices/Word-to-Image/.NET/Word-document-to-image/Word-document-to-image/Program.cs @@ -2,6 +2,7 @@ using Syncfusion.DocIO.DLS; using Syncfusion.DocIORenderer; using System.Diagnostics; +using System.Reflection.Metadata; class Program { @@ -13,22 +14,26 @@ static void Main() using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { // Open an existing Word document - WordDocument document = new WordDocument(fileStreamPath,FormatType.Docx); - DocIORenderer renderer = new DocIORenderer(); - //Convert the entire Word document to images. - Stream[] imageStreams = document.RenderAsImages(); - for (int i = 0; i < imageStreams.Length; i++) + using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx)) { - //Save the image stream as file. - string imagePath = Path.Combine(Path.GetFullPath(@"Output/Images"), $"WordToImage_{i + 1}.jpg"); - using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write)) + using (DocIORenderer renderer = new DocIORenderer()) { - imageStreams[i].CopyTo(fileStreamOutput); - } + //Convert the entire Word document to images. + Stream[] imageStreams = document.RenderAsImages(); + for (int i = 0; i < imageStreams.Length; i++) + { + //Save the image stream as file. + string imagePath = Path.Combine(Path.GetFullPath(@"Output/Images"), $"WordToImage_{i + 1}.jpg"); + using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write)) + { + imageStreams[i].CopyTo(fileStreamOutput); + } + } + } } stopwatch.Stop(); Console.WriteLine($"Word To Image processed in {stopwatch.Elapsed.TotalSeconds} seconds"); - } + } } catch (Exception ex) { From d1d7384301d21461187f4e3aa7cfab3175798d2e Mon Sep 17 00:00:00 2001 From: Kathiresan4347 <159137198+Kathiresan4347@users.noreply.github.com> Date: Tue, 10 Feb 2026 17:12:38 +0530 Subject: [PATCH 2/2] 1006383-Removed unwanted using statement --- .../Word-document-to-image/Word-document-to-image/Program.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Performance-metrices/Word-to-Image/.NET/Word-document-to-image/Word-document-to-image/Program.cs b/Performance-metrices/Word-to-Image/.NET/Word-document-to-image/Word-document-to-image/Program.cs index b8a5a107..41d15fd4 100644 --- a/Performance-metrices/Word-to-Image/.NET/Word-document-to-image/Word-document-to-image/Program.cs +++ b/Performance-metrices/Word-to-Image/.NET/Word-document-to-image/Word-document-to-image/Program.cs @@ -2,7 +2,6 @@ using Syncfusion.DocIO.DLS; using Syncfusion.DocIORenderer; using System.Diagnostics; -using System.Reflection.Metadata; class Program {