diff --git a/HTML to PDF/Blink/Access-a-webpage-using-HTTP-GET/.NET/Access-a-webpage-using-HTTP-GET/Program.cs b/HTML to PDF/Blink/Access-a-webpage-using-HTTP-GET/.NET/Access-a-webpage-using-HTTP-GET/Program.cs index f0a37cb9..36ed9e4a 100644 --- a/HTML to PDF/Blink/Access-a-webpage-using-HTTP-GET/.NET/Access-a-webpage-using-HTTP-GET/Program.cs +++ b/HTML to PDF/Blink/Access-a-webpage-using-HTTP-GET/.NET/Access-a-webpage-using-HTTP-GET/Program.cs @@ -29,8 +29,10 @@ PdfDocument document = htmlConverter.Convert(urlToConvert); //Create file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document -document.Save(fileStream); +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/Access-a-webpage-using-HTTP-POST/.NET/Access-a-webpage-using-HTTP-POST/Program.cs b/HTML to PDF/Blink/Access-a-webpage-using-HTTP-POST/.NET/Access-a-webpage-using-HTTP-POST/Program.cs index 225e5efd..3a971064 100644 --- a/HTML to PDF/Blink/Access-a-webpage-using-HTTP-POST/.NET/Access-a-webpage-using-HTTP-POST/Program.cs +++ b/HTML to PDF/Blink/Access-a-webpage-using-HTTP-POST/.NET/Access-a-webpage-using-HTTP-POST/Program.cs @@ -26,8 +26,10 @@ PdfDocument document = htmlConverter.Convert("https://www.example.com"); //Create file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document -document.Save(fileStream); +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/Accessible_PDF_In_HTML_to_PDF/.NET/Accessible PDF/Program.cs b/HTML to PDF/Blink/Accessible_PDF_In_HTML_to_PDF/.NET/Accessible PDF/Program.cs index a125a47e..07a0e6ff 100644 --- a/HTML to PDF/Blink/Accessible_PDF_In_HTML_to_PDF/.NET/Accessible PDF/Program.cs +++ b/HTML to PDF/Blink/Accessible_PDF_In_HTML_to_PDF/.NET/Accessible PDF/Program.cs @@ -18,8 +18,11 @@ htmlConverter.ConverterSettings = settings; //Convert URL to PDF. PdfDocument document = htmlConverter.Convert("file:///D:/PDF-Examples/HTML%20to%20PDF/Blink/Accessible_PDF_In_HTML_to_PDF/.NET/Accessible%20PDF/Data/Input.html"); -//Save and close the PDF document. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); -//Save and close the PDF document -document.Save(fileStream); +//Create file stream. +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/Adjusting-the-HTML-content-size-in-PDF-document/.NET/Adjusting-the-HTML-content-size-in-PDF-document/Program.cs b/HTML to PDF/Blink/Adjusting-the-HTML-content-size-in-PDF-document/.NET/Adjusting-the-HTML-content-size-in-PDF-document/Program.cs index b1d3188a..e9b4de1d 100644 --- a/HTML to PDF/Blink/Adjusting-the-HTML-content-size-in-PDF-document/.NET/Adjusting-the-HTML-content-size-in-PDF-document/Program.cs +++ b/HTML to PDF/Blink/Adjusting-the-HTML-content-size-in-PDF-document/.NET/Adjusting-the-HTML-content-size-in-PDF-document/Program.cs @@ -26,8 +26,10 @@ PdfDocument document = htmlConverter.Convert("https://www.google.com"); //Create file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document. -document.Save(fileStream); +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/Convert-HTML-form-to-PDF-fillable-form/.NET/Convert-HTML-form-to-PDF-fillable-form/Program.cs b/HTML to PDF/Blink/Convert-HTML-form-to-PDF-fillable-form/.NET/Convert-HTML-form-to-PDF-fillable-form/Program.cs index 6c4f9141..2ec26666 100644 --- a/HTML to PDF/Blink/Convert-HTML-form-to-PDF-fillable-form/.NET/Convert-HTML-form-to-PDF-fillable-form/Program.cs +++ b/HTML to PDF/Blink/Convert-HTML-form-to-PDF-fillable-form/.NET/Convert-HTML-form-to-PDF-fillable-form/Program.cs @@ -25,9 +25,11 @@ //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert(Path.GetFullPath(@"Data/Input.html")); -//Create file stream to save the PDF document. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document -document.Save(fileStream); +//Create file stream. +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); \ No newline at end of file diff --git a/HTML to PDF/Blink/Convert-HTML-to-PDF-in-offline-mode/.NET/Convert-HTML-to-PDF-in-offline-mode/Program.cs b/HTML to PDF/Blink/Convert-HTML-to-PDF-in-offline-mode/.NET/Convert-HTML-to-PDF-in-offline-mode/Program.cs index 48172c0a..4af43350 100644 --- a/HTML to PDF/Blink/Convert-HTML-to-PDF-in-offline-mode/.NET/Convert-HTML-to-PDF-in-offline-mode/Program.cs +++ b/HTML to PDF/Blink/Convert-HTML-to-PDF-in-offline-mode/.NET/Convert-HTML-to-PDF-in-offline-mode/Program.cs @@ -26,8 +26,10 @@ PdfDocument document = htmlConverter.Convert("https://www.google.com"); //Create file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document. -document.Save(fileStream); +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); \ No newline at end of file diff --git a/HTML to PDF/Blink/Convert-form-authenticated-webpage-to-PDF-document/.NET/Convert-form-authenticated-webpage-to-PDF-document/Program.cs b/HTML to PDF/Blink/Convert-form-authenticated-webpage-to-PDF-document/.NET/Convert-form-authenticated-webpage-to-PDF-document/Program.cs index f78e1b5d..45f7a709 100644 --- a/HTML to PDF/Blink/Convert-form-authenticated-webpage-to-PDF-document/.NET/Convert-form-authenticated-webpage-to-PDF-document/Program.cs +++ b/HTML to PDF/Blink/Convert-form-authenticated-webpage-to-PDF-document/.NET/Convert-form-authenticated-webpage-to-PDF-document/Program.cs @@ -27,8 +27,10 @@ PdfDocument document = htmlConverter.Convert("https://www.example.com"); //Create file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document -document.Save(fileStream); +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/Convert-partial-webpage-to-PDF-document/.NET/Convert-partial-webpage-to-PDF-document/Program.cs b/HTML to PDF/Blink/Convert-partial-webpage-to-PDF-document/.NET/Convert-partial-webpage-to-PDF-document/Program.cs index 61e7ee89..1ece57a1 100644 --- a/HTML to PDF/Blink/Convert-partial-webpage-to-PDF-document/.NET/Convert-partial-webpage-to-PDF-document/Program.cs +++ b/HTML to PDF/Blink/Convert-partial-webpage-to-PDF-document/.NET/Convert-partial-webpage-to-PDF-document/Program.cs @@ -19,8 +19,10 @@ PdfDocument document = htmlConverter.ConvertPartialHtml(Path.GetFullPath(@"Data/Input.html"), "picture"); //Create file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document -document.Save(fileStream); +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); \ No newline at end of file diff --git a/HTML to PDF/Blink/Convert-the-HTML-string-to-PDF-document/.NET/Convert-the-HTML-string-to-PDF-document/Program.cs b/HTML to PDF/Blink/Convert-the-HTML-string-to-PDF-document/.NET/Convert-the-HTML-string-to-PDF-document/Program.cs index fbd54a3b..382df904 100644 --- a/HTML to PDF/Blink/Convert-the-HTML-string-to-PDF-document/.NET/Convert-the-HTML-string-to-PDF-document/Program.cs +++ b/HTML to PDF/Blink/Convert-the-HTML-string-to-PDF-document/.NET/Convert-the-HTML-string-to-PDF-document/Program.cs @@ -22,9 +22,11 @@ //Convert HTML string to PDF document. PdfDocument document = htmlConverter.Convert(htmlText, baseUrl); -//Create the file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document -document.Save(fileStream); +//Create file stream. +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/Convert-token-based-authenticated-webpage-to-PDF/.NET/Convert-token-based-authenticated-webpage-to-PDF/Program.cs b/HTML to PDF/Blink/Convert-token-based-authenticated-webpage-to-PDF/.NET/Convert-token-based-authenticated-webpage-to-PDF/Program.cs index 8f4825e5..ad86231c 100644 --- a/HTML to PDF/Blink/Convert-token-based-authenticated-webpage-to-PDF/.NET/Convert-token-based-authenticated-webpage-to-PDF/Program.cs +++ b/HTML to PDF/Blink/Convert-token-based-authenticated-webpage-to-PDF/.NET/Convert-token-based-authenticated-webpage-to-PDF/Program.cs @@ -24,8 +24,10 @@ PdfDocument document = htmlConverter.Convert("https://httpbin.org/headers"); //Create file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document. -document.Save(fileStream); +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/Convert-website-URL-to-PDF-document/.NET/Convert-website-URL-to-PDF-document/Program.cs b/HTML to PDF/Blink/Convert-website-URL-to-PDF-document/.NET/Convert-website-URL-to-PDF-document/Program.cs index 07197cf2..23fc3419 100644 --- a/HTML to PDF/Blink/Convert-website-URL-to-PDF-document/.NET/Convert-website-URL-to-PDF-document/Program.cs +++ b/HTML to PDF/Blink/Convert-website-URL-to-PDF-document/.NET/Convert-website-URL-to-PDF-document/Program.cs @@ -18,9 +18,11 @@ //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.google.com"); -//Create file stream for PDF document. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document -document.Save(fileStream); +//Create file stream. +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); \ No newline at end of file diff --git a/HTML to PDF/Blink/Convert-windows-authenticated-webpage-to-PDF-document/.NET/Convert-windows-authenticated-webpage-to-PDF-document/Program.cs b/HTML to PDF/Blink/Convert-windows-authenticated-webpage-to-PDF-document/.NET/Convert-windows-authenticated-webpage-to-PDF-document/Program.cs index 45626242..c6f43f37 100644 --- a/HTML to PDF/Blink/Convert-windows-authenticated-webpage-to-PDF-document/.NET/Convert-windows-authenticated-webpage-to-PDF-document/Program.cs +++ b/HTML to PDF/Blink/Convert-windows-authenticated-webpage-to-PDF-document/.NET/Convert-windows-authenticated-webpage-to-PDF-document/Program.cs @@ -24,9 +24,11 @@ //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.example.com"); -//Create file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document -document.Save(fileStream); +//Create file stream. +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/Create-TOC-while-converting-HTML-to-PDF/.NET/Create-TOC-while-converting-HTML-to-PDF/Program.cs b/HTML to PDF/Blink/Create-TOC-while-converting-HTML-to-PDF/.NET/Create-TOC-while-converting-HTML-to-PDF/Program.cs index accebaa8..07603d66 100644 --- a/HTML to PDF/Blink/Create-TOC-while-converting-HTML-to-PDF/.NET/Create-TOC-while-converting-HTML-to-PDF/Program.cs +++ b/HTML to PDF/Blink/Create-TOC-while-converting-HTML-to-PDF/.NET/Create-TOC-while-converting-HTML-to-PDF/Program.cs @@ -23,9 +23,11 @@ //Convert HTML to PDF document. PdfDocument document = htmlConverter.Convert(Path.GetFullPath(@"Data/Input.html")); -//Create file stream to save the PDF document. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document. -document.Save(fileStream); +//Create file stream. +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/Create-custom-style-TOC-when-converting-HTML-to-PDF/.NET/Create-custom-style-TOC-when-converting-HTML-to-PDF/Program.cs b/HTML to PDF/Blink/Create-custom-style-TOC-when-converting-HTML-to-PDF/.NET/Create-custom-style-TOC-when-converting-HTML-to-PDF/Program.cs index ce50095d..6718d1b2 100644 --- a/HTML to PDF/Blink/Create-custom-style-TOC-when-converting-HTML-to-PDF/.NET/Create-custom-style-TOC-when-converting-HTML-to-PDF/Program.cs +++ b/HTML to PDF/Blink/Create-custom-style-TOC-when-converting-HTML-to-PDF/.NET/Create-custom-style-TOC-when-converting-HTML-to-PDF/Program.cs @@ -34,9 +34,11 @@ //Convert HTML to PDF document. PdfDocument document = htmlConverter.Convert(Path.GetFullPath(@"Data/Input.html")); -//Create file stream to save the PDF document. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document -document.Save(fileStream); +//Create file stream. +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/Creating-bookmarks-while-converting-HTML-to-PDF/.NET/Creating-bookmarks-while-converting-HTML-to-PDF/Program.cs b/HTML to PDF/Blink/Creating-bookmarks-while-converting-HTML-to-PDF/.NET/Creating-bookmarks-while-converting-HTML-to-PDF/Program.cs index 25eef6b0..dca5d8bd 100644 --- a/HTML to PDF/Blink/Creating-bookmarks-while-converting-HTML-to-PDF/.NET/Creating-bookmarks-while-converting-HTML-to-PDF/Program.cs +++ b/HTML to PDF/Blink/Creating-bookmarks-while-converting-HTML-to-PDF/.NET/Creating-bookmarks-while-converting-HTML-to-PDF/Program.cs @@ -24,8 +24,10 @@ PdfDocument document = htmlConverter.Convert(Path.GetFullPath(@"Data/Input.html")); //Create file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document. -document.Save(fileStream); +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/HTML-Footer-Background-Colour/.NET/HTML-Footer-Background-Colour/Program.cs b/HTML to PDF/Blink/HTML-Footer-Background-Colour/.NET/HTML-Footer-Background-Colour/Program.cs index 8cbf3253..6cdc7af5 100644 --- a/HTML to PDF/Blink/HTML-Footer-Background-Colour/.NET/HTML-Footer-Background-Colour/Program.cs +++ b/HTML to PDF/Blink/HTML-Footer-Background-Colour/.NET/HTML-Footer-Background-Colour/Program.cs @@ -27,8 +27,11 @@ //Convert the URL to a PDF document. PdfDocument document = htmlConverter.Convert("
Hello World
",string.Empty); -//Create a filestream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite); -//Save and close a PDF document. -document.Save(fileStream); +//Create file stream. +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); \ No newline at end of file diff --git a/HTML to PDF/Blink/HTML-Header-and-Footer/.NET/HTML-Header-and-Footer/Program.cs b/HTML to PDF/Blink/HTML-Header-and-Footer/.NET/HTML-Header-and-Footer/Program.cs index e2f3877b..9ea240af 100644 --- a/HTML to PDF/Blink/HTML-Header-and-Footer/.NET/HTML-Header-and-Footer/Program.cs +++ b/HTML to PDF/Blink/HTML-Header-and-Footer/.NET/HTML-Header-and-Footer/Program.cs @@ -33,10 +33,13 @@ static void Main(string[] args) { //Convert the URL to a PDF document. PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); - //Create a filestream. - FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - //Save and close a PDF document. - document.Save(fileStream); + //Create file stream. + using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) + { + //Save the PDF document + document.Save(fileStream); + } + //Close the document. document.Close(true); } } diff --git a/HTML to PDF/Blink/HTML-to-PDF-Header-and-footer/.NET/HTML-to-PDF-Header-and-footer/Program.cs b/HTML to PDF/Blink/HTML-to-PDF-Header-and-footer/.NET/HTML-to-PDF-Header-and-footer/Program.cs index 68c933ca..7b7b0c96 100644 --- a/HTML to PDF/Blink/HTML-to-PDF-Header-and-footer/.NET/HTML-to-PDF-Header-and-footer/Program.cs +++ b/HTML to PDF/Blink/HTML-to-PDF-Header-and-footer/.NET/HTML-to-PDF-Header-and-footer/Program.cs @@ -42,10 +42,12 @@ static void Main(string[] args) { //Convert URL to PDF. PdfDocument document = htmlConverter.Convert("https://www.google.com/"); - //Create a file stream. - FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - //Save a PDF document to the file stream. - document.Save(fileStream); + //Create file stream. + using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) + { + //Save the PDF document + document.Save(fileStream); + } //Close the document. document.Close(true); } diff --git a/HTML to PDF/Blink/HTML-to-PDF-margin-customization/.NET/HTML-to-PDF-margin-customization/Program.cs b/HTML to PDF/Blink/HTML-to-PDF-margin-customization/.NET/HTML-to-PDF-margin-customization/Program.cs index 1d30613c..6703d8ae 100644 --- a/HTML to PDF/Blink/HTML-to-PDF-margin-customization/.NET/HTML-to-PDF-margin-customization/Program.cs +++ b/HTML to PDF/Blink/HTML-to-PDF-margin-customization/.NET/HTML-to-PDF-margin-customization/Program.cs @@ -21,10 +21,12 @@ static void Main(string[] args) { //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.google.com"); - //Create a file stream. - FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - //Save the PDF document to the file stream. - document.Save(fileStream); + //Create file stream. + using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) + { + //Save the PDF document + document.Save(fileStream); + } //Close the document. document.Close(true); } diff --git a/HTML to PDF/Blink/HTML-to-PDF-page-orientation-customization/.NET/HTML-to-PDF-page-orientation-customization/Program.cs b/HTML to PDF/Blink/HTML-to-PDF-page-orientation-customization/.NET/HTML-to-PDF-page-orientation-customization/Program.cs index 3272ec14..111b7e23 100644 --- a/HTML to PDF/Blink/HTML-to-PDF-page-orientation-customization/.NET/HTML-to-PDF-page-orientation-customization/Program.cs +++ b/HTML to PDF/Blink/HTML-to-PDF-page-orientation-customization/.NET/HTML-to-PDF-page-orientation-customization/Program.cs @@ -21,10 +21,12 @@ static void Main(string[] args) { //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.google.com"); - //Create a file stream. - FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - //Save a PDF document to a file stream. - document.Save(fileStream); + //Create file stream. + using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) + { + //Save the PDF document + document.Save(fileStream); + } //Close the document. document.Close(true); } diff --git a/HTML to PDF/Blink/HTML-to-PDF-page-size-customization/.NET/HTML-to-PDF-page-size-customization/Program.cs b/HTML to PDF/Blink/HTML-to-PDF-page-size-customization/.NET/HTML-to-PDF-page-size-customization/Program.cs index 55d498ad..5d09475c 100644 --- a/HTML to PDF/Blink/HTML-to-PDF-page-size-customization/.NET/HTML-to-PDF-page-size-customization/Program.cs +++ b/HTML to PDF/Blink/HTML-to-PDF-page-size-customization/.NET/HTML-to-PDF-page-size-customization/Program.cs @@ -21,10 +21,12 @@ static void Main(string[] args) { //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.google.com"); - //Create a file stream. - FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite); - //Save the PDF document to the file stream. - document.Save(fileStream); + //Create file stream. + using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) + { + //Save the PDF document + document.Save(fileStream); + } //Close the document. document.Close(true); } diff --git a/HTML to PDF/Blink/HTML-to-PDF-rotate-page/.NET/HTML-to-PDF-rotate-page/Program.cs b/HTML to PDF/Blink/HTML-to-PDF-rotate-page/.NET/HTML-to-PDF-rotate-page/Program.cs index 3b90d853..2e588884 100644 --- a/HTML to PDF/Blink/HTML-to-PDF-rotate-page/.NET/HTML-to-PDF-rotate-page/Program.cs +++ b/HTML to PDF/Blink/HTML-to-PDF-rotate-page/.NET/HTML-to-PDF-rotate-page/Program.cs @@ -21,10 +21,12 @@ static void Main(string[] args) { //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.google.com"); - //Create a file stream. - FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite); - //Save a PDF document to a file stream. - document.Save(fileStream); + //Create file stream. + using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) + { + //Save the PDF document + document.Save(fileStream); + } //Close the document. document.Close(true); } diff --git a/HTML to PDF/Blink/HTML-to-PDF-scale-property/Scale_property_in_HTML_converter/Program.cs b/HTML to PDF/Blink/HTML-to-PDF-scale-property/Scale_property_in_HTML_converter/Program.cs index 7981f4ca..62964522 100644 --- a/HTML to PDF/Blink/HTML-to-PDF-scale-property/Scale_property_in_HTML_converter/Program.cs +++ b/HTML to PDF/Blink/HTML-to-PDF-scale-property/Scale_property_in_HTML_converter/Program.cs @@ -18,9 +18,11 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); -//Create a file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite); -//Save a PDF document to a file stream. -document.Save(fileStream); +//Create file stream. +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} //Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/Inject_custom_CSS_to_HTML/.NET/Inject_custom_CSS_to_HTML/Program.cs b/HTML to PDF/Blink/Inject_custom_CSS_to_HTML/.NET/Inject_custom_CSS_to_HTML/Program.cs index 6ce3f894..b020c753 100644 --- a/HTML to PDF/Blink/Inject_custom_CSS_to_HTML/.NET/Inject_custom_CSS_to_HTML/Program.cs +++ b/HTML to PDF/Blink/Inject_custom_CSS_to_HTML/.NET/Inject_custom_CSS_to_HTML/Program.cs @@ -22,8 +22,11 @@ //Convert the URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.google.com"); -//Create file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); -//Save and close the PDF document. -document.Save(fileStream); +//Create file stream. +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); \ No newline at end of file diff --git a/HTML to PDF/Blink/Inject_custom_JavaScript_to_HTML/.NET/Inject_custom_JavaScript_to_HTML/Program.cs b/HTML to PDF/Blink/Inject_custom_JavaScript_to_HTML/.NET/Inject_custom_JavaScript_to_HTML/Program.cs index 609107e5..6810aec6 100644 --- a/HTML to PDF/Blink/Inject_custom_JavaScript_to_HTML/.NET/Inject_custom_JavaScript_to_HTML/Program.cs +++ b/HTML to PDF/Blink/Inject_custom_JavaScript_to_HTML/.NET/Inject_custom_JavaScript_to_HTML/Program.cs @@ -27,8 +27,11 @@ //Convert the URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); -//Create a filestream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); -//Save and close the PDF document. -document.Save(fileStream); +//Create file stream. +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/Selection-of-media-type-while-converting-HTML-to-PDF/.NET/Selection-of-media-type-while-converting-HTML-to-PDF/Program.cs b/HTML to PDF/Blink/Selection-of-media-type-while-converting-HTML-to-PDF/.NET/Selection-of-media-type-while-converting-HTML-to-PDF/Program.cs index 5ddc7685..5d531393 100644 --- a/HTML to PDF/Blink/Selection-of-media-type-while-converting-HTML-to-PDF/.NET/Selection-of-media-type-while-converting-HTML-to-PDF/Program.cs +++ b/HTML to PDF/Blink/Selection-of-media-type-while-converting-HTML-to-PDF/.NET/Selection-of-media-type-while-converting-HTML-to-PDF/Program.cs @@ -26,8 +26,10 @@ PdfDocument document = htmlConverter.Convert("https://www.google.com"); //Create file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document. -document.Save(fileStream); +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); \ No newline at end of file diff --git a/HTML to PDF/Blink/Set-additional-delay-while-converting-HTML-to-PDF/.NET/Set-additional-delay-while-converting-HTML-to-PDF/Program.cs b/HTML to PDF/Blink/Set-additional-delay-while-converting-HTML-to-PDF/.NET/Set-additional-delay-while-converting-HTML-to-PDF/Program.cs index 96b812cb..2127f89d 100644 --- a/HTML to PDF/Blink/Set-additional-delay-while-converting-HTML-to-PDF/.NET/Set-additional-delay-while-converting-HTML-to-PDF/Program.cs +++ b/HTML to PDF/Blink/Set-additional-delay-while-converting-HTML-to-PDF/.NET/Set-additional-delay-while-converting-HTML-to-PDF/Program.cs @@ -26,8 +26,10 @@ PdfDocument document = htmlConverter.Convert("https://www.google.com"); //Create file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and Close the PDF document. -document.Save(fileStream); +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/Set-temporary-path-while-converting-HTML-to-PDF/.NET/Set-temporary-path-while-converting-HTML-to-PDF/Program.cs b/HTML to PDF/Blink/Set-temporary-path-while-converting-HTML-to-PDF/.NET/Set-temporary-path-while-converting-HTML-to-PDF/Program.cs index 862e57f8..c5c865a1 100644 --- a/HTML to PDF/Blink/Set-temporary-path-while-converting-HTML-to-PDF/.NET/Set-temporary-path-while-converting-HTML-to-PDF/Program.cs +++ b/HTML to PDF/Blink/Set-temporary-path-while-converting-HTML-to-PDF/.NET/Set-temporary-path-while-converting-HTML-to-PDF/Program.cs @@ -26,8 +26,10 @@ PdfDocument document = htmlConverter.Convert("https://www.google.com"); //Create file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document -document.Save(fileStream); +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/Set-windows-status-while-converting-HTML-to-PDF/.NET/Set-windows-status-while-converting-HTML-to-PDF/Program.cs b/HTML to PDF/Blink/Set-windows-status-while-converting-HTML-to-PDF/.NET/Set-windows-status-while-converting-HTML-to-PDF/Program.cs index 8920daec..92b206ad 100644 --- a/HTML to PDF/Blink/Set-windows-status-while-converting-HTML-to-PDF/.NET/Set-windows-status-while-converting-HTML-to-PDF/Program.cs +++ b/HTML to PDF/Blink/Set-windows-status-while-converting-HTML-to-PDF/.NET/Set-windows-status-while-converting-HTML-to-PDF/Program.cs @@ -26,8 +26,10 @@ PdfDocument document = htmlConverter.Convert(Path.GetFullPath(@"Data/Input.html")); //Create file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); - -//Save and close the PDF document -document.Save(fileStream); +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/Set_blink_path_in_HTML_to_PDF/.NET/Set_blink_path_in_HTML_to_PDF/Program.cs b/HTML to PDF/Blink/Set_blink_path_in_HTML_to_PDF/.NET/Set_blink_path_in_HTML_to_PDF/Program.cs index a8a31dc0..7a3b6117 100644 --- a/HTML to PDF/Blink/Set_blink_path_in_HTML_to_PDF/.NET/Set_blink_path_in_HTML_to_PDF/Program.cs +++ b/HTML to PDF/Blink/Set_blink_path_in_HTML_to_PDF/.NET/Set_blink_path_in_HTML_to_PDF/Program.cs @@ -19,8 +19,11 @@ //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); -//Create file stream to save the PDF document. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); -//Save and close the PDF document. -document.Save(fileStream); +//Create file stream. +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} +//Close the document. document.Close(true); diff --git a/HTML to PDF/Blink/Time-out-support-in-HTML-to-PDF/.NET/Time-out-support-in-HTML-to-PDF/Program.cs b/HTML to PDF/Blink/Time-out-support-in-HTML-to-PDF/.NET/Time-out-support-in-HTML-to-PDF/Program.cs index 2723b3ba..311d045e 100644 --- a/HTML to PDF/Blink/Time-out-support-in-HTML-to-PDF/.NET/Time-out-support-in-HTML-to-PDF/Program.cs +++ b/HTML to PDF/Blink/Time-out-support-in-HTML-to-PDF/.NET/Time-out-support-in-HTML-to-PDF/Program.cs @@ -18,9 +18,11 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.google.com"); -//Create a file stream. -FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite); -//Save and close the PDF document. -document.Save(fileStream); +//Create file stream. +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document + document.Save(fileStream); +} //Close the document. document.Close(true);