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..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 @@ -13,22 +13,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) {