From 1fd0fc3c376701518d563bba806dce023c2dbdd0 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Fri, 3 Oct 2025 15:02:41 +0530 Subject: [PATCH 1/9] 985014-ug: Added Feedback content in HTML to PDF conversion. --- .../Conversions/HTML-To-PDF/NET/features.md | 624 ++++++++++++------ 1 file changed, 429 insertions(+), 195 deletions(-) diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/features.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/features.md index ec42661a9..e1e027228 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/features.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/features.md @@ -16,13 +16,16 @@ To convert website URL or local HTML file to PDF document using [Convert](https: {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Convert-website-URL-to-PDF-document/.NET/Convert-website-URL-to-PDF-document/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.google.com"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); @@ -30,13 +33,16 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize HTML to PDF converter Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() 'Convert URL to PDF Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") + 'Save and close the PDF document document.Save("Output.pdf") - document.Close(True) {% endhighlight %} @@ -63,6 +69,9 @@ To convert the HTML string to PDF using [Convert](https://help.syncfusion.com/cr {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Convert-the-HTML-string-to-PDF-document/.NET/Convert-the-HTML-string-to-PDF-document/Program.cs, 300" %} +using Syncfusion.Drawing; +using Syncfusion.HtmlConverter; + //Initialize HTML to PDF converter HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -72,15 +81,18 @@ string baseUrl = @"C:/Temp/HTMLFiles/"; //Convert URL to PDF PdfDocument document = htmlConverter.Convert(htmlText, baseUrl); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.HtmlConverter + 'Initialize HTML to PDF converter Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -118,18 +130,24 @@ To convert website URL or local HTML file to Image using [ConvertToImage](https: {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Convert-website-URL-to-image-file/.NET/Convert-website-URL-to-image-file/Program.cs, 300" %} +using Syncfusion.Drawing; +using Syncfusion.HtmlConverter; + //Initialize HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); //Convert URL to Image Image image = htmlConverter.ConvertToImage("https://www.google.com"); -byte[] imageByte = image.ImageData; -//Save the image -File.WriteAllBytes("Output.jpg", imageByte); +//Save and dispose the image file +image[0].Save("Output.jpg"); +image[0].Dispose(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Drawing; +using Syncfusion.HtmlConverter; + //Initialize HTML to PDF converter HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); //Convert URL to Image @@ -142,6 +160,9 @@ image[0].Dispose(); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.HtmlConverter + 'Initialize HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() 'Convert URL to Image @@ -175,6 +196,9 @@ To convert the HTML string to Image using [ConvertToImage](https://help.syncfusi {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Convert-the-HTML-string-to-image-file/.NET/Convert-the-HTML-string-to-image-file/Program.cs, 300" %} +using Syncfusion.Drawing; +using Syncfusion.HtmlConverter; + //Initialize HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -184,14 +208,17 @@ string baseUrl = @"C:/Temp/HTMLFiles/"; //Convert HTML string to Image Image image = htmlConverter.ConvertToImage(htmlText, baseUrl); -byte[] imageByte = image.ImageData; -//Save the image -File.WriteAllBytes("Output.jpg", imageByte); +//Save and dispose the image file +image[0].Save("Output.jpg"); +image[0].Dispose(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.HtmlConverter; + //Initialize HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -209,6 +236,9 @@ image[0].Dispose(); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.HtmlConverter + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -247,6 +277,9 @@ To convert SVG file to Image using [ConvertToImage](https://help.syncfusion.com/ {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Converting_SVG_to_Image_using_HtmlConverter/.NET/Converting_SVG_to_Image_using_HtmlConverter/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.HtmlConverter; + // Create an instance of the Syncfusion HtmlToPdfConverter HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -266,6 +299,9 @@ File.WriteAllBytes("Output.jpg"), imageBytes); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Drawing +Imports Syncfusion.HtmlConverter + ' Create an instance of the Syncfusion HtmlToPdfConverter Dim htmlConverter As New HtmlToPdfConverter() @@ -295,6 +331,9 @@ The Blink HTML converter supports enabling or disabling the JavaScript using [En {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Disable-JavaScript-when-convert-HTML-to-PDF/.NET/Disable-JavaScript-when-convert-HTML-to-PDF/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -306,15 +345,18 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.google.com"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -346,6 +388,9 @@ Refer the following code example to set the [AdditionalDelay](https://help.syncf {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Set-additional-delay-while-converting-HTML-to-PDF/.NET/Set-additional-delay-while-converting-HTML-to-PDF/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -357,15 +402,18 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.google.com"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -396,6 +444,9 @@ The Blink HTML converter support preserving URL links from HTML to PDF using [En {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Disable-URL-links-while-converting-HTML-to-PDF/.NET/Disable-URL-links-while-converting-HTML-to-PDF/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -407,15 +458,18 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.google.com"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = NewHtmlToPdfConverter() @@ -449,6 +503,9 @@ Refer to the following code snippet. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Creating-bookmarks-while-converting-HTML-to-PDF/.NET/Creating-bookmarks-while-converting-HTML-to-PDF/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -460,14 +517,17 @@ htmlConverter.ConverterSettings = settings; //Convert HTML to PDF PdfDocument document = htmlConverter.Convert("input.html"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -544,6 +604,9 @@ Refer to the following code snippet. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Create-TOC-while-converting-HTML-to-PDF/.NET/Create-TOC-while-converting-HTML-to-PDF/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -555,15 +618,18 @@ htmlConverter.ConverterSettings = settings; //Convert HTML to PDF PdfDocument document = htmlConverter.Convert("input.html"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -638,6 +704,12 @@ Refer to the following code snippet. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Create-custom-style-TOC-when-converting-HTML-to-PDF/.NET/Create-custom-style-TOC-when-converting-HTML-to-PDF/Program.cs, 300" %} +using Syncfusion.Drawing; +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.HtmlToPdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -656,15 +728,21 @@ htmlConverter.ConverterSettings = settings; //Convert HTML to PDF PdfDocument document = htmlConverter.Convert("input.html"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Drawing +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.HtmlToPdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -744,6 +822,9 @@ The Blink HTML Converter allows selection of media type while converting HTML to {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Selection-of-media-type-while-converting-HTML-to-PDF/.NET/Selection-of-media-type-while-converting-HTML-to-PDF/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -755,15 +836,18 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.google.com"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -795,6 +879,9 @@ Blink rendering engine provides support for converting HTML forms to PDF fillabl {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Convert-HTML-form-to-PDF-fillable-form/.NET/Convert-HTML-form-to-PDF-fillable-form/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -806,15 +893,18 @@ htmlConverter.ConverterSettings = settings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -844,6 +934,9 @@ The webpage you want to convert may protected with windows authentication. Blink {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Convert-windows-authenticated-webpage-to-PDF-document/.NET/Convert-windows-authenticated-webpage-to-PDF-document/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + // Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -855,15 +948,18 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.example.com"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -893,6 +989,9 @@ The Blink HTML converter provides support for form authentication by using [Cook {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Convert-form-authenticated-webpage-to-PDF-document/.NET/Convert-form-authenticated-webpage-to-PDF-document/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + // Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -905,15 +1004,18 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.example.com"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -944,6 +1046,9 @@ The Blink HTML converter supports token-based authentication by using the [HttpR {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Convert-token-based-authenticated-webpage-to-PDF/.NET/Convert-token-based-authenticated-webpage-to-PDF/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize HTML to PDF converter HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -955,15 +1060,18 @@ htmlConverter.ConverterSettings = settings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.example.com"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize HTML to PDF converter Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -997,6 +1105,9 @@ Refer to the following code snippet. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Convert-HTML-to-PDF-in-offline-mode/.NET/Convert-HTML-to-PDF-in-offline-mode/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -1008,15 +1119,18 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.google.com"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -1047,6 +1161,9 @@ Refer to the following code snippet to access a webpage using HTTP POST. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Access-a-webpage-using-HTTP-POST/.NET/Access-a-webpage-using-HTTP-POST/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -1059,15 +1176,18 @@ htmlConverter.ConverterSettings = settings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.example.com"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -1096,6 +1216,9 @@ Use the following code snippet to access a webpage using HTTP GET. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Access-a-webpage-using-HTTP-GET/.NET/Access-a-webpage-using-HTTP-GET/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -1107,15 +1230,18 @@ string urlToConvert = url + httpGetData; //Convert URL to PDF PdfDocument document = htmlConverter.Convert(urlToConvert); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -1159,8 +1285,10 @@ You can specify the manual proxy settings for the conversion using the [ProxySet {% highlight c# tabtitle="C# [Cross-platform]" %} -//Initialize the HTML to PDF converter. +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; +//Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); BlinkConverterSettings settings = new BlinkConverterSettings(); @@ -1173,15 +1301,18 @@ htmlConverter.ConverterSettings = settings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.google.com"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -1214,6 +1345,10 @@ N> The HTML converter internally uses the viewport size in points. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Adjusting-the-HTML-content-size-in-PDF-document/.NET/Adjusting-the-HTML-content-size-in-PDF-document/Program.cs, 300" %} +using Syncfusion.Drawing; +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -1225,15 +1360,19 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.google.com"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -1263,20 +1402,26 @@ The Blink rendering engine provides support for converting only the part of an H {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Convert-partial-webpage-to-PDF-document/.NET/Convert-partial-webpage-to-PDF-document/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); //Convert Partial webpage to PDF PdfDocument document = htmlConverter.ConvertPartialHtml("input.html", "pic"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -1327,6 +1472,9 @@ Refer to the following code snippet. {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -1338,15 +1486,18 @@ htmlConverter.ConverterSettings = settings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.google.com"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -1374,6 +1525,9 @@ Getting height of the HTML content in PDF document is possible by using the [Pdf {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -1383,15 +1537,18 @@ PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com", out l //Draw the text at the end of HTML content PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 11); document.Pages[document.Pages.Count - 1].Graphics.DrawString("End of HTML content", font, PdfBrushes.Red, new PointF(0, layoutResult.Bounds.Bottom)); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -1423,6 +1580,9 @@ Refer to the following code snippet. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Set-windows-status-while-converting-HTML-to-PDF/.NET/Set-windows-status-while-converting-HTML-to-PDF/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + // Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -1434,15 +1594,18 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("input.html"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -1492,6 +1655,9 @@ To set the page size when converting HTML to PDF, utilize the [PdfPageSize](http {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/HTML-to-PDF-page-size-customization/.NET/HTML-to-PDF-page-size-customization/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); //Initialize blink converter settings. @@ -1503,10 +1669,8 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.google.com"); -//Create a file stream. -FileStream fileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite); //Save the PDF document to the file stream. -document.Save(fileStream); +document.Save("Output.pdf"); //Close the document. document.Close(true); @@ -1514,6 +1678,9 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() Dim blinkConverterSettings As BlinkConverterSettings = New BlinkConverterSettings() @@ -1524,10 +1691,8 @@ htmlConverter.ConverterSettings = blinkConverterSettings 'Convert URL to PDF document. Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") -'Create file stream to save the PDF document. -Dim fileStream As FileStream = New FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite) 'Save and close the PDF document. -document.Save(fileStream) +document.Save("Output.pdf") document.Close(True) {% endhighlight %} @@ -1544,6 +1709,9 @@ To set the margin when converting HTML to PDF, utilize the [Margin](https://help {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/HTML-to-PDF-margin-customization/.NET/HTML-to-PDF-margin-customization/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); //Initialize blink converter settings. @@ -1555,10 +1723,8 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.google.com"); -//Create a file stream. -FileStream fileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite); //Save the PDF document to the file stream. -document.Save(fileStream); +document.Save("Output.pdf"); //Close the document. document.Close(true); @@ -1566,6 +1732,9 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() Dim blinkConverterSettings As BlinkConverterSettings = New BlinkConverterSettings() @@ -1576,10 +1745,8 @@ htmlConverter.ConverterSettings = blinkConverterSettings 'Convert URL to PDF document. Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") -'Create file stream to save the PDF document. -Dim fileStream As FileStream = New FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite) 'Save and close the PDF document. -document.Save(fileStream) +document.Save("Output.pdf") document.Close(True) {% endhighlight %} @@ -1596,6 +1763,11 @@ To set the header and footer when converting HTML to PDF, utilize the [PdfHeader {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/HTML-to-PDF-Header-and-footer/.NET/HTML-to-PDF-Header-and-footer/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf; +using Syncfusion.Drawing; + //Initialize HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); @@ -1626,10 +1798,8 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF. PdfDocument document = htmlConverter.Convert("https://www.google.com/"); -//Create a file stream. -FileStream fileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite); //Save a PDF document to the file stream. -document.Save(fileStream); +document.Save("Output.pdf"); //Close the document. document.Close(true); @@ -1637,6 +1807,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf +Imports System.Drawing + 'Initialize HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() Dim blinkConverterSettings As BlinkConverterSettings = New BlinkConverterSettings() @@ -1668,10 +1843,8 @@ htmlConverter.ConverterSettings = blinkConverterSettings 'Convert URL to PDF document. Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") -'Create file stream to save the PDF document. -Dim fileStream As FileStream = New FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite) 'Save and close the PDF document. -document.Save(fileStream) +document.Save("Output.pdf") document.Close(True) {% endhighlight %} @@ -1688,6 +1861,9 @@ To set the Orientation when converting HTML to PDF, utilize the [Orientation](ht {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/HTML-to-PDF-page-orientation-customization/.NET/HTML-to-PDF-page-orientation-customization/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); //Initialize blink converter settings. @@ -1699,10 +1875,8 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.google.com"); -//Create a file stream. -FileStream fileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite); -//Save a PDF document to a file stream. -document.Save(fileStream); +//Save a PDF document. +document.Save("Output.pdf"); //Close the document. document.Close(true); @@ -1710,6 +1884,9 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() Dim blinkConverterSettings As BlinkConverterSettings = New BlinkConverterSettings() @@ -1720,10 +1897,8 @@ htmlConverter.ConverterSettings = blinkConverterSettings 'Convert URL to PDF document. Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") -'Create file stream to save the PDF document. -Dim fileStream As FileStream = New FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite) 'Save and close the PDF document. -document.Save(fileStream) +document.Save("Output.pdf") document.Close(True) {% endhighlight %} @@ -1740,6 +1915,9 @@ To set the page rotation when converting HTML to PDF, utilize the [PageRotateAng {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/HTML-to-PDF-rotate-page/.NET/HTML-to-PDF-rotate-page/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); //Initialize blink converter settings. @@ -1751,10 +1929,8 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.google.com"); -//Create a file stream. -FileStream fileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite); //Save a PDF document to a file stream. -document.Save(fileStream); +document.Save("Output.pdf"); //Close the document. document.Close(true); @@ -1762,6 +1938,9 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() Dim blinkConverterSettings As BlinkConverterSettings = New BlinkConverterSettings() @@ -1772,10 +1951,8 @@ htmlConverter.ConverterSettings = blinkConverterSettings 'Convert URL to PDF document. Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") -'Create file stream to save the PDF document. -Dim fileStream As FileStream = New FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite) 'Save and close the PDF document. -document.Save(fileStream) +document.Save("Output.pdf") document.Close(True) {% endhighlight %} @@ -1792,6 +1969,10 @@ When converting HTML to PDF, you can set an HTML file as header and footer. Use {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/HTML-Header-and-Footer/.NET/HTML-Header-and-Footer/Program.cs, 300" %} +using Syncfusion.Drawing; +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); //Initialize blink converter settings. @@ -1811,16 +1992,18 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert the URL to a PDF document. PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); -//Create a filestream. -FileStream fileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite); //Save and close a PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf +Imports System.Drawing + 'Initialize HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() 'Initialize blink converter settings. @@ -1840,10 +2023,8 @@ htmlConverter.ConverterSettings = blinkConverterSettings 'Convert the URL to a PDF document. Dim document As PdfDocument = htmlConverter.Convert("https://www.syncfusion.com") -'Create a filestream. -Dim fileStream As FileStream = New FileStream("Output.pdf", FileMode.CreateNew, FileAccess.ReadWrite) 'Save and close a PDF document. -document.Save(fileStream) +document.Save("Output.pdf") document.Close(True) {% endhighlight %} @@ -1864,6 +2045,10 @@ The Blink rendering engine supports the injection of custom CSS to be applied to {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Inject_custom_CSS_to_HTML/.NET/Inject_custom_CSS_to_HTML/Program.cs, 300" %} +using Syncfusion.Drawing; +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); @@ -1875,16 +2060,19 @@ blinkConverterSettings.Css = "body {\r\n background-color: red; \r\n}"; htmlConverter.ConverterSettings = blinkConverterSettings; //Convert the URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); -//Create a filestream. -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf +Imports System.Drawing + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() Dim blinkConverterSettings As BlinkConverterSettings = New BlinkConverterSettings() @@ -1896,10 +2084,9 @@ blinkConverterSettings.Css = "body {\r\n background-color: red; \r\n}" htmlConverter.ConverterSettings = blinkConverterSettings 'Convert the URL to PDF document. Dim document As PdfDocument = htmlConverter.Convert(https://www.syncfusion.com) -'Create a filestream. -Dim fileStream As FileStream = New FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite) + 'Save and close the PDF document. -document.Save(fileStream) +document.Save("Output.pdf") document.Close(true) {% endhighlight %} @@ -1918,6 +2105,10 @@ The Blink rendering engine offers support for injecting custom JavaScript to be {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Inject_custom_JavaScript_to_HTML/.NET/Inject_custom_JavaScript_to_HTML/Program.cs, 300" %} +using Syncfusion.Drawing; +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); @@ -1929,16 +2120,19 @@ blinkConverterSettings.JavaScript = "document.querySelectorAll('img').forEach((n htmlConverter.ConverterSettings = blinkConverterSettings; //Convert the URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); -//Create a filestream. -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf +Imports System.Drawing + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() Dim blinkConverterSettings As BlinkConverterSettings = New BlinkConverterSettings() @@ -1950,10 +2144,9 @@ blinkConverterSettings.JavaScript = "document.querySelectorAll('img').forEach((n htmlConverter.ConverterSettings = blinkConverterSettings 'Convert the URL to PDF document. Dim document As PdfDocument = htmlConverter.Convert("https://www.syncfusion.com") -'Create a filestream. -Dim fileStream As FileStream = New FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite) + 'Save and close the PDF document. -document.Save(fileStream) +document.Save("Output.pdf") document.Close(true) {% endhighlight %} @@ -1972,14 +2165,16 @@ The Blink rendering engine provides support for reusing the browser process to o {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Optimize-HTML-to-PDF-performance/.NET/Optimize-HTML-to-PDF-performance/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); //Reuse the browser instance. htmlConverter.ReuseBrowserProcess = true; //Create PDF document. PdfDocument document = new PdfDocument(); -//Create memory stream. -MemoryStream memoryStream = new MemoryStream(); + for (int i = 0; i < 10; i++) { //Initialize the blink converter settings. @@ -1991,9 +2186,8 @@ for (int i = 0; i < 10; i++) //Convert the URL to PDF document. document = htmlConverter.Convert("https://www.google.com"); //Save and close the PDF document. - document.Save(memoryStream); + document.Save("Output.pdf"); document.Close(true); - File.WriteAllBytes("ReuseBrowserProcess" + Guid.NewGuid().ToString() + ".pdf", memoryStream.ToArray()); } //Close HTML converter. htmlConverter.Close(); @@ -2002,14 +2196,16 @@ htmlConverter.Close(); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() 'Reuse the browser instance. htmlConverter.ReuseBrowserProcess = True 'Create PDF document. Dim document As PdfDocument = New PdfDocument() -'Create memory stream. -Dim memoryStream As MemoryStream = New MemoryStream() + For i As Integer = 0 To 10 - 1 'Initialize the blink converter settings. Dim settings As BlinkConverterSettings = New BlinkConverterSettings() @@ -2020,9 +2216,8 @@ For i As Integer = 0 To 10 - 1 'Convert the URL to PDF document. document = htmlConverter.Convert("https://www.google.com") 'Save and close the PDF document. - document.Save(memoryStream) + document.Save("Output.pdf") document.Close(True) - File.WriteAllBytes("ReuseBrowserProcess" & Guid.NewGuid().ToString() & ".pdf", memoryStream.ToArray()) Next 'Close HTML converter. htmlConverter.Close() @@ -2045,6 +2240,9 @@ The temporary path can be changed by using the [TempPath](https://help.syncfusio {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Set-temporary-path-while-converting-HTML-to-PDF/.NET/Set-temporary-path-while-converting-HTML-to-PDF/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -2056,15 +2254,18 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.google.com"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -2096,6 +2297,9 @@ N> * The BlinkBinaries also available in NuGet package installed location if you {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Set_blink_path_in_HTML_to_PDF/.NET/Set_blink_path_in_HTML_to_PDF/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); @@ -2106,16 +2310,17 @@ htmlConverter.ConverterSettings = blinkConverterSettings; //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("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() Dim blinkConverterSettings As BlinkConverterSettings = New BlinkConverterSettings() @@ -2126,10 +2331,8 @@ htmlConverter.ConverterSettings = blinkConverterSettings 'Convert URL to PDF document. Dim document As PdfDocument = htmlConverter.Convert("https://www.syncfusion.com") -'Create file stream to save the PDF document. -Dim fileStream As FileStream = New FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite) 'Save and close the PDF document. -document.Save(fileStream) +document.Save("Output.pdf") document.Close(True) {% endhighlight %} @@ -2149,6 +2352,9 @@ Refer to the following code snippet to resize the page content size. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/HTML-to-PDF-scale-property/.NET/Scale_property_in_HTML_converter/Program.cs, 300" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); //Initialize the blink converter settings. @@ -2170,6 +2376,9 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As New HtmlToPdfConverter() 'Initialize the blink converter settings. @@ -2201,6 +2410,9 @@ N> EnableAutoScaling and GetHtmlBounds cannot be used simultaneously in the HTM {% highlight c# tabtitle="C# [Cross-platform]" %} + using Syncfusion.HtmlConverter; + using Syncfusion.Pdf; + // Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); // Initialize BlinkConverterSettings to configure the Blink rendering engine. @@ -2214,10 +2426,7 @@ N> EnableAutoScaling and GetHtmlBounds cannot be used simultaneously in the HTM // Converts the HTML file to a PDF document, using the path of the HTML file. PdfDocument document = htmlConverter.Convert(Path.GetFullPath("../../../Input.html")); // Save the generated PDF document to a specified output file. - using (FileStream fileStream = new FileStream("Output.pdf", FileMode.Create)) - { - document.Save(fileStream); - } + document.Save("Output.pdf"); // Close the document. document.Close(true); @@ -2225,6 +2434,9 @@ N> EnableAutoScaling and GetHtmlBounds cannot be used simultaneously in the HTM {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + Imports Syncfusion.HtmlConverter + Imports Syncfusion.Pdf + ' Initialize the HTML to PDF converter. Dim htmlConverter As New HtmlToPdfConverter() ' Initialize BlinkConverterSettings to configure the Blink rendering engine. @@ -2238,9 +2450,7 @@ N> EnableAutoScaling and GetHtmlBounds cannot be used simultaneously in the HTM ' Converts the HTML file to a PDF document, using the path of the HTML file. Dim document As PdfDocument = htmlConverter.Convert(Path.GetFullPath("../../../Input.html")) ' Save the generated PDF document to a specified output file. - Using fileStream As New FileStream("Output.pdf", FileMode.Create) - document.Save(fileStream) - End Using + document.Save("Output.pdf") ' Close the document. document.Close() @@ -2257,6 +2467,9 @@ Refer to the following code snippet to set the timeout for HTML to PDF conversio {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Time-out-support-in-HTML-to-PDF/.NET/Time-out-support-in-HTML-to-PDF/Program.cs, 300" %} + + using Syncfusion.HtmlConverter; + using Syncfusion.Pdf; //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -2268,17 +2481,18 @@ Refer to the following code snippet to set the timeout for HTML to PDF conversio htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("https://www.google.com"); - //Create a file stream. - FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. - document.Save(fileStream); - //Close the document. + document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + Imports Syncfusion.HtmlConverter + Imports Syncfusion.Pdf + 'Initialize the HTML to PDF converter. Dim htmlConverter As New HtmlToPdfConverter() 'Initialize the blink converter settings. @@ -2289,11 +2503,9 @@ Refer to the following code snippet to set the timeout for HTML to PDF conversio htmlConverter.ConverterSettings = blinkConverterSettings 'Convert URL to PDF Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") - 'Create a file stream. - Dim fileStream As New FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite) + 'Save and close the PDF document. - document.Save(fileStream) - 'Close the document. + document.Save("Output.pdf") document.Close(True) {% endhighlight %} @@ -2310,6 +2522,9 @@ The [WaitForExternalFonts](https://help.syncfusion.com/cr/document-processing/Sy {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + // Initialize HTML to PDF converter HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); // Initialize Blink converter settings @@ -2322,19 +2537,18 @@ htmlConverter.ConverterSettings = blinkConverterSettings; // Convert URL (or file path) to PDF PdfDocument document = htmlConverter.Convert(Path.GetFullPath("Input.html")); -// Create a FileStream to save the PDF document to a file -using (FileStream fileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.Write)) -{ - // Save the PDF document to the file stream - document.Save(fileStream); -} -// Close the document after saving +// Save the PDF document. +document.Save("Output.pdf"); +// Close the document. document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + ' Initialize HTML to PDF converter Dim htmlConverter As New HtmlToPdfConverter() ' Initialize Blink converter settings @@ -2347,13 +2561,10 @@ htmlConverter.ConverterSettings = blinkConverterSettings ' Convert URL (or file path) to PDF Dim document As PdfDocument = htmlConverter.Convert(Path.GetFullPath("Input.html")) -' Create a FileStream to save the PDF document to a file -Using fileStream As New FileStream("Output.pdf", FileMode.Create, FileAccess.Write) - ' Save the PDF document to the file stream - document.Save(fileStream) -End Using -' Close the document after saving -document.Close() +' Save the PDF document. +document.Save("Output.pdf") +' Close the document. +document.Close(True) {% endhighlight %} @@ -2367,7 +2578,10 @@ N> This support fully depends on the Chromium headless browser. Our converter pr {% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Accessible_PDF_In_HTML_to_PDF/.NET/Accessible%20PDF/Program.cs, 300" %} + + using Syncfusion.HtmlConverter; + using Syncfusion.Pdf; //Initialize HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -2379,15 +2593,17 @@ N> This support fully depends on the Chromium headless browser. Our converter pr htmlConverter.ConverterSettings = settings; //Convert URL to PDF. PdfDocument document = htmlConverter.Convert("Input.html"); - //Save and close the PDF document. - FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); - document.Save(fileStream); + //Save and close the PDF document. + document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + Imports Syncfusion.HtmlConverter + Imports Syncfusion.Pdf + 'Initialize HTML to PDF converter. Dim htmlConverter As New HtmlToPdfConverter() 'Initialize the BlinkConverterSettings. @@ -2398,9 +2614,8 @@ N> This support fully depends on the Chromium headless browser. Our converter pr htmlConverter.ConverterSettings = settings 'Convert URL to PDF. Dim document As PdfDocument = htmlConverter.Convert("Input.html") - 'Save and close the PDF document. - Dim fileStream As New FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite) - document.Save(fileStream) + 'Save and close the PDF document. + document.Save("Output.pdf") document.Close(True) {% endhighlight %} @@ -2418,6 +2633,9 @@ The Blink HTML converter support adding the image background from HTML to Image {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Image_Background_In_HTML_to_PDF/.NET/Image_Background_In_HTML_to_PDF/Program.cs, 300" %} + using Syncfusion.Drawing; + using Syncfusion.HtmlConverter; + //Initialize HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); //Initialize the BlinkConverterSettings. @@ -2428,14 +2646,17 @@ The Blink HTML converter support adding the image background from HTML to Image htmlConverter.ConverterSettings = settings; //Convert HTML to Image. Image image = htmlConverter.ConvertToImage("Input.html"); - //Save the Image. - byte[] imageByte = image.ImageData; - File.WriteAllBytes("Output.png", imageByte); + //Save and dispose the image file + image[0].Save("Output.png"); + image[0].Dispose(); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + Imports Syncfusion.HtmlConverter + Imports Syncfusion.Pdf + ' Initialize HTML to PDF converter. Dim htmlConverter As New HtmlToPdfConverter() ' Initialize the BlinkConverterSettings. @@ -2446,9 +2667,9 @@ The Blink HTML converter support adding the image background from HTML to Image htmlConverter.ConverterSettings = settings ' Convert HTML to Image. Dim image As Image = htmlConverter.ConvertToImage("Input.html") - ' Save the Image. - Dim imageByte As Byte() = image.ImageData - File.WriteAllBytes("Output.png", imageByte) + ' Save and dispose the image file + image[0].Save("Output.png") + image[0].Dispose() {% endhighlight %} @@ -2464,7 +2685,10 @@ N> EnableAutoScaling and GetHtmlBounds cannot be used simultaneously in the HTML {% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Get-Bounds-in-HTML-file/.NET/Get-Bounds-in-HTML-file/Program.cs, 300" %} + + using Syncfusion.Drawing; + using Syncfusion.HtmlConverter; // Initialize HTML to PDF converter HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -2478,13 +2702,17 @@ N> EnableAutoScaling and GetHtmlBounds cannot be used simultaneously in the HTML htmlConverter.ConverterSettings = blinkConverterSettings; // Convert the HTML file to an image Image image = htmlConverter.ConvertToImage(Path.GetFullPath("Input.html")); - // Save the image as a PNG file - File.WriteAllBytes("Output.png", image.ImageData); + //Save and dispose the image file + image[0].Save("Output.png"); + image[0].Dispose(); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + Imports Syncfusion.HtmlConverter + Imports System.Pdf + ' Initialize HTML to PDF converter Dim htmlConverter As New HtmlToPdfConverter() ' Initialize Blink converter settings @@ -2497,8 +2725,9 @@ N> EnableAutoScaling and GetHtmlBounds cannot be used simultaneously in the HTML htmlConverter.ConverterSettings = blinkConverterSettings ' Convert the HTML file to an image Dim image As Image = htmlConverter.ConvertToImage(Path.GetFullPath("Input.html")) - ' Save the image as a PNG file - File.WriteAllBytes("Output.png", image.ImageData) + ' Save and dispose the image file + image[0].Save("Output.png") + image[0].Dispose() {% endhighlight %} @@ -2514,7 +2743,11 @@ Refer to the following code sample to Disabling local file access. {% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Disabling-local-file-access-HTML-to-PDF/.NET/Disabling-local-file-access-HTML-to-PDF/Program.cs, 300" %} + +using Syncfusion.Drawing; +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; // Initialize HTML to PDF converter with a using statement to ensure disposal using (HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter()) @@ -2522,7 +2755,7 @@ using (HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter()) // Initialize Blink converter settings BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); // Set Blink viewport size - blinkConverterSettings.ViewPortSize = new Syncfusion.Drawing.Size(1280, 0); + blinkConverterSettings.ViewPortSize = new Size(1280, 0); // Restricts external CSS and images in local HTML content blinkConverterSettings.EnableLocalFileAccess = false; @@ -2534,12 +2767,8 @@ using (HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter()) // Convert HTML to PDF document using (PdfDocument document = htmlConverter.Convert(html, "")) { - // Create a file stream with a using statement to ensure disposal - using (FileStream fileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - // Save the PDF document to the file stream - document.Save(fileStream); - } + // Save the PDF document. + document.Save("Output.pdf"); } } @@ -2547,12 +2776,16 @@ using (HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + ' Initialize HTML to PDF converter with a Using statement to ensure disposal Using htmlConverter As New HtmlToPdfConverter() ' Initialize Blink converter settings Dim blinkConverterSettings As New BlinkConverterSettings() ' Set Blink viewport size - blinkConverterSettings.ViewPortSize = New Syncfusion.Drawing.Size(1280, 0) + blinkConverterSettings.ViewPortSize = New Size(1280, 0) ' Restricts external CSS and images in local HTML content blinkConverterSettings.EnableLocalFileAccess = False @@ -2563,11 +2796,8 @@ Using htmlConverter As New HtmlToPdfConverter() Dim html As String = File.ReadAllText("sample.html") ' Convert HTML to PDF document Using document As PdfDocument = htmlConverter.Convert(html, "") - ' Create a file stream with a Using statement to ensure disposal - Using fileStream As New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - ' Save the PDF document to the file stream - document.Save(fileStream) - End Using + ' Save the PDF document to the file stream + document.Save("Output.pdf") End Using End Using @@ -2589,6 +2819,10 @@ The following code examples demonstrate how to convert HTML to PDF and programma {% highlight c# tabtitle="C# [Cross-platform]" %} + using Syncfusion.Drawing; + using Syncfusion.HtmlConverter; + using Syncfusion.Pdf; + // Initialize the HTML to PDF converter using the Blink rendering engine HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -2608,9 +2842,9 @@ The following code examples demonstrate how to convert HTML to PDF and programma // Save the PDF to a memory stream for further processing using (MemoryStream stream = new MemoryStream()) { - document.Save(stream); // Save converted PDF to memory - stream.Position = 0; // Reset stream position - document.Close(true); // Close the original document + document.Save(stream); + stream.Position = 0; + document.Close(true); // Replace the "signature" textarea with an actual signature field AddPdfSignatureField(stream); @@ -2646,13 +2880,8 @@ public void AddPdfSignatureField(MemoryStream stream) // Add the new signature field to the form loadedForm.Fields.Add(signatureField); } - - // Save the modified document to disk - using (FileStream outputStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.Write)) - { - loadedDocument.Save(outputStream); - } - + // Save the modified document. + loadedDocument.Save("Output.pdf"); // Close the document and release resources loadedDocument.Close(true); } @@ -2662,6 +2891,10 @@ public void AddPdfSignatureField(MemoryStream stream) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + Imports System.Drawing + Imports Syncfusion.HtmlConverter + Imports Syncfusion.Pdf + ' Initialize the HTML to PDF converter using the Blink rendering engine Dim htmlConverter As New HtmlToPdfConverter() @@ -2749,6 +2982,9 @@ Refer to the following code sample to wait until browser navigation completes. {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + // Initialize HTML to PDF converter. HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter(); // Initialize BlinkConverterSettings. @@ -2763,10 +2999,7 @@ htmlToPdfConverter.ConverterSettings = settings; PdfDocument document = htmlToPdfConverter.Convert("input.html"); // Save the document. -using (FileStream fileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.Write)) -{ - document.Save(fileStream); -} +document.Save("Output.pdf"); // Close the document. document.Close(true); @@ -2774,6 +3007,9 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + ' Initialize HTML to PDF converter. Dim htmlToPdfConverter As New HtmlToPdfConverter() ' Initialize BlinkConverterSettings. @@ -2788,9 +3024,7 @@ htmlToPdfConverter.ConverterSettings = settings Dim document As PdfDocument = htmlToPdfConverter.Convert("input.html") ' Save the document. -Using fileStream As New FileStream("Output.pdf", FileMode.Create, FileAccess.Write) - document.Save(fileStream) -End Using +document.Save("Output.pdf") ' Close the document. document.Close(True) From 8f72c3c95037e475a57e7ddb139493deb7f6b431 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Fri, 3 Oct 2025 15:35:30 +0530 Subject: [PATCH 2/9] 985014-ug: Added NuGet and Assemblies files. --- Document-Processing-toc.html | 6 + .../HTML-To-PDF/NET/Assemblies-Required.md | 80 ++++++++++ .../HTML-To-PDF/NET/Converting-HTML-to-PDF.md | 140 ------------------ .../NET/NuGet-Packages-Required.md | 112 ++++++++++++++ 4 files changed, 198 insertions(+), 140 deletions(-) create mode 100644 Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Assemblies-Required.md create mode 100644 Document-Processing/PDF/Conversions/HTML-To-PDF/NET/NuGet-Packages-Required.md diff --git a/Document-Processing-toc.html b/Document-Processing-toc.html index f14fcf2f0..c2024c8fc 100644 --- a/Document-Processing-toc.html +++ b/Document-Processing-toc.html @@ -2284,6 +2284,12 @@
  • Overview
  • +
  • + Assemblies Required +
  • +
  • + NuGet Packages Required +
  • Getting Started
      diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Assemblies-Required.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Assemblies-Required.md new file mode 100644 index 000000000..d90677af7 --- /dev/null +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Assemblies-Required.md @@ -0,0 +1,80 @@ +--- +title: Assemblies Required for HTML to PDF | Syncfusion +description: This section explains the Syncfusion assemblies required for performing HTML to PDF conversion +platform: document-processing +control: PDF +documentation: UG +keywords: Assemblies +--- +# Assemblies Required for HTML to PDF Conversion + +Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for [Windows](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/advanced-installation#windows), [Linux](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/advanced-installation#linux), and [Mac](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/advanced-installation#mac) respectively. Please refer to the [advanced installation](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/advanced-installation) steps for more details. + + + + + + + + + + + + + + + + + + +
      PlatformsAssemblies
      + WinForms
      + WPF
      + ASP.NET MVC +
      +
        +
      • Syncfusion.Compression.Base.dll
      • +
      • Syncfusion.Pdf.Base.dll
      • +
      • Syncfusion.HtmlConverter.Base.dll
      • +
      • Newtonsoft.Json package (v13.0.1 or above)
      • +
      +
      + .NET/.NET Core
      + Blazor +
      +
        +
      • Syncfusion.Compression.Portable.dll
      • +
      • Syncfusion.Pdf.Portable.dll
      • +
      • Syncfusion.HtmlConverter.Portable.dll
      • +
      • Newtonsoft.Json package (v13.0.1 or above)
      • +
      +
      + +**RETIRED PRODUCTS** + + + + + + + + + + + + + + +
      Platform(s)Assembly
      + ASP.NET + +
        +
      • Syncfusion.Compression.Base.dll
      • +
      • Syncfusion.Pdf.Base.dll
      • +
      • Syncfusion.HtmlConverter.Base.dll
      • +
      • Newtonsoft.Json package (v13.0.1 or above)
      • +
      +
      + +N> HTML to PDF conversion is not supported in Silverlight, Windows Phone, WinRT, Universal, Xamarin and UWP applications + diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md index bb47d6e8e..ae5789109 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md @@ -33,146 +33,6 @@ Syncfusion® HTML-to-PDF converter will work seamlessly in various * Compatible with .NET Framework 4.5 and above. * Compatible with .NET Core 2.0 and above. -## Install HTML to PDF .NET library to your project - -Include the HTML to PDF converter in your project using two approaches. -* NuGet packages (Recommended) -* Assemblies. - -### NuGet Packages Required (Recommended) - -Directly install the NuGet packages to your .NET application from [nuget.org](https://www.nuget.org/). - -N> The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement. - - - - - - - - - - - - - - - - - - - - - - - - -
      Platform(s)NuGet Package
      -(.NET Core, .NET 8, .NET 9) Windows - -{{'[Syncfusion.HtmlToPdfConverter.Net.Windows.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Windows/)'| markdownify }} -
      -(.NET Core, .NET 8, .NET 9) Linux - -{{'[Syncfusion.HtmlToPdfConverter.Net.Linux.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Linux/)'| markdownify }} -
      -(.NET Core, .NET 8, .NET 9) Mac - -{{'[Syncfusion.HtmlToPdfConverter.Net.Mac.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Mac/)'| markdownify }} -
      -(.NET Core, .NET 8, .NET 9) AWS - -{{'[Syncfusion.HtmlToPdfConverter.Net.Aws.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Aws/)'| markdownify }} -
      - -Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages. - - - - - - - - - - - - - - - - - - - - - - - - -
      Platform(s)NuGet Package
      -Windows Forms - -{{'[Syncfusion.HtmlToPdfConverter.WinForms.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.WinForms/)'| markdownify }} -
      -WPF - -{{'[Syncfusion.HtmlToPdfConverter.Wpf.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Wpf/)'| markdownify }} -
      -ASP.NET - -{{'[Syncfusion.HtmlToPdfConverter.AspNet.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.AspNet/)'| markdownify }} -
      -ASP.NET MVC - -{{'[Syncfusion.HtmlToPdfConverter.AspNet.Mvc5.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.AspNet.Mvc5/)'| markdownify }} -
      - -### Assemblies Required - -Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for [Windows](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/advanced-installation#windows), [Linux](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/advanced-installation#linux), and [Mac](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/advanced-installation#mac), respectively. Please refer to the [advanced installation](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/advanced-installation) steps for more details. - - - - - - - - - - - - - - -
      -Platforms -Assemblies -
      -WinForms -WPF -ASP.NET -ASP.NET MVC - -
        -
      • Syncfusion.Compression.Base.dll
      • -
      • Syncfusion.Pdf.Base.dll
      • -
      • Syncfusion.HtmlConverter.Base.dll
      • -
      • Newtonsoft.Json package (v13.0.1 or above)
      • -
      -
      -.NET/.NET Core -Blazor - -
        -
      • Syncfusion.Compression.Portable.dll
      • -
      • Syncfusion.Pdf.Portable.dll
      • -
      • Syncfusion.HtmlConverter.Portable.dll
      • -
      • Newtonsoft.Json package (v13.0.1 or above)
      • -
      -
      - ## Get Started with HTML to PDF conversion ### Convert HTML to PDF in C# diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/NuGet-Packages-Required.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/NuGet-Packages-Required.md new file mode 100644 index 000000000..67fd9278e --- /dev/null +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/NuGet-Packages-Required.md @@ -0,0 +1,112 @@ +--- +title: NuGet Packages for HTML to PDF | Syncfusion +description: This section outlines the NuGet packages required to perform HTML to PDF conversion using the Syncfusion PDF library across various platforms +platform: document-processing +control: PDF +documentation: UG +--- +# NuGet Packages Required for HTML to PDF + +For converting HTML to PDF file, the following NuGet packages need to to be installed in your .NET application from [nuget.org](https://www.nuget.org/). + +N> The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement. + + + + + + + + + + + + + + + + + + + + + + + + +
      Platform(s)NuGet Package
      +(.NET Core, .NET 5, .NET 6 and .NET 8) Windows + +{{'[Syncfusion.HtmlToPdfConverter.Net.Windows.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Windows/)'| markdownify }} +
      +(.NET Core, .NET 5, .NET 6 and .NET 8) Linux + +{{'[Syncfusion.HtmlToPdfConverter.Net.Linux.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Linux/)'| markdownify }} +
      +(.NET Core, .NET 5, .NET 6 and .NET 8) Mac + +{{'[Syncfusion.HtmlToPdfConverter.Net.Mac.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Mac/)'| markdownify }} +
      +(.NET Core, .NET 5, .NET 6 and .NET 8) Aws + +{{'[Syncfusion.HtmlToPdfConverter.Net.Aws.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Aws/)'| markdownify }} +
      + +Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages. + + + + + + + + + + + + + + + + + + + + +
      Platform(s)NuGet Package
      +Windows Forms + +{{'[Syncfusion.HtmlToPdfConverter.WinForms.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.WinForms/)'| markdownify }} +
      +WPF + +{{'[Syncfusion.HtmlToPdfConverter.Wpf.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Wpf/)'| markdownify }} +
      +ASP.NET MVC + +{{'[Syncfusion.HtmlToPdfConverter.AspNet.Mvc5.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.AspNet.Mvc5/)'| markdownify }} +
      + +### RETIRED PRODUCTS + + + + + + + + + + + + + + +
      Platform(s)NuGet Package
      + ASP.NET + + {{'[Syncfusion.HtmlToPdfConverter.AspNet.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.AspNet/)'| markdownify }} +
      + +N> 1. HTML to PDF conversion is not supported in Silverlight, Windows Phone, WinRT, Universal, Xamarin and UWP applications. +N> 2. Starting with v21.1.XX, The package structure is changed if you reference Syncfusion® HTML to the PDF library from the NuGet feed. The Blink binaries paths are automatically added and do not need to add it manually. However, if you need to refer the blink binaries paths in your application manually, please use the BlinkPath in BlinkConverterSettings. Get the BlinkBinaries from the NuGet package runtime folder or get the binaries by installing the HTML converter installer. \ No newline at end of file From 9e70de2861dd6f1d46962e6396ac9d15e2994ba8 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Fri, 3 Oct 2025 15:37:39 +0530 Subject: [PATCH 3/9] 985014-ug: Updated proper link. --- Document-Processing/PDF/PDF-Library/NET/Overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Overview.md b/Document-Processing/PDF/PDF-Library/NET/Overview.md index a3f86d4b6..77462159a 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Overview.md +++ b/Document-Processing/PDF/PDF-Library/NET/Overview.md @@ -21,7 +21,7 @@ The following list shows the key features available in the Essential® Date: Fri, 3 Oct 2025 15:53:17 +0530 Subject: [PATCH 4/9] 985014-ug: Resolved CI failures. --- .../PDF/Conversions/HTML-To-PDF/NET/Assemblies-Required.md | 2 +- Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Assemblies-Required.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Assemblies-Required.md index d90677af7..578d039cd 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Assemblies-Required.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Assemblies-Required.md @@ -1,6 +1,6 @@ --- title: Assemblies Required for HTML to PDF | Syncfusion -description: This section explains the Syncfusion assemblies required for performing HTML to PDF conversion +description: This section details the Syncfusion assemblies required to implement HTML-to-PDF conversion functionality using the .NET PDF library. platform: document-processing control: PDF documentation: UG diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md index 29a0ec508..27f49d765 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md @@ -5,7 +5,7 @@ platform: document-processing control: PDF documentation: UG --- -# Converting HTML to PDF +# Converting HTML to PDF Document The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage. From 5cc3d1061f060640f5297165462a99754258608c Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Fri, 3 Oct 2025 16:06:38 +0530 Subject: [PATCH 5/9] 985014-ug: Resolved CI failures. --- .../PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md | 2 +- Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md index ae5789109..9cd29d5be 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md @@ -5,7 +5,7 @@ platform: document-processing control: PDF documentation: UG --- -# Converting HTML to PDF +# Converting HTML to PDF Document The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage. diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md index 27f49d765..29a0ec508 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md @@ -5,7 +5,7 @@ platform: document-processing control: PDF documentation: UG --- -# Converting HTML to PDF Document +# Converting HTML to PDF The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage. From 335a7e472d5052acc81e10c96455d2e3a89baa63 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Fri, 3 Oct 2025 16:16:02 +0530 Subject: [PATCH 6/9] 985014-ug: Updated proper H1 tag. --- .../PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md index 9cd29d5be..6bd4ef707 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md @@ -5,7 +5,7 @@ platform: document-processing control: PDF documentation: UG --- -# Converting HTML to PDF Document +# Converting HTML to a PDF Document The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage. From cc33bd771a6ba9b9eb77b3d59b2d29fe4f98f89e Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Fri, 3 Oct 2025 18:47:15 +0530 Subject: [PATCH 7/9] 985014-ug: Resolved the given feedback. --- .../HTML-To-PDF/NET/Assemblies-Required.md | 2 +- ...rt-HTML-to-PDF-in-AWS-Elastic-Beanstalk.md | 2 + ...-in-Azure-App-Service-Linux-with-docker.md | 1 + ...-to-PDF-in-Azure-Function-App-Container.md | 2 +- .../HTML-To-PDF/NET/Converting-HTML-to-PDF.md | 5 +- .../NET/NuGet-Packages-Required.md | 2 +- .../Conversions/HTML-To-PDF/NET/aspnet-mvc.md | 2 + .../PDF/Conversions/HTML-To-PDF/NET/blazor.md | 6 ++ .../Conversions/HTML-To-PDF/NET/features.md | 55 ++++++++----------- .../PDF/Conversions/HTML-To-PDF/NET/linux.md | 8 +-- .../PDF/Conversions/HTML-To-PDF/NET/mac.md | 4 ++ .../Conversions/HTML-To-PDF/NET/net-core.md | 6 +- .../NET/Working-with-Document-Conversions.md | 47 +++++++++++----- 13 files changed, 80 insertions(+), 62 deletions(-) diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Assemblies-Required.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Assemblies-Required.md index 578d039cd..ce6960b7c 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Assemblies-Required.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Assemblies-Required.md @@ -76,5 +76,5 @@ Get the following required assemblies by downloading the HTML converter installe -N> HTML to PDF conversion is not supported in Silverlight, Windows Phone, WinRT, Universal, Xamarin and UWP applications +N> HTML to PDF conversion is not supported in .NET MAUI, Xamarin, and UWP applications. diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Convert-HTML-to-PDF-in-AWS-Elastic-Beanstalk.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Convert-HTML-to-PDF-in-AWS-Elastic-Beanstalk.md index fd162f171..8f55df2c7 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Convert-HTML-to-PDF-in-AWS-Elastic-Beanstalk.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Convert-HTML-to-PDF-in-AWS-Elastic-Beanstalk.md @@ -71,6 +71,8 @@ public IActionResult BlinkToPDF() MemoryStream stream = new MemoryStream(); //Save the document to the memory stream. document.Save(stream); + //Close the document + document.Close(true); return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "BlinkLinuxDockerAWSBeanstalk.pdf"); } diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Convert-HTML-to-PDF-in-Azure-App-Service-Linux-with-docker.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Convert-HTML-to-PDF-in-Azure-App-Service-Linux-with-docker.md index d65215daf..d75a84e1f 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Convert-HTML-to-PDF-in-Azure-App-Service-Linux-with-docker.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Convert-HTML-to-PDF-in-Azure-App-Service-Linux-with-docker.md @@ -84,6 +84,7 @@ public ActionResult ExportToPDF() MemoryStream stream = new MemoryStream(); //Save and close a PDF document. document.Save(stream); + document.Close(true); return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "URL_to_PDF.pdf"); } diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Convert-HTML-to-PDF-in-Azure-Function-App-Container.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Convert-HTML-to-PDF-in-Azure-Function-App-Container.md index 4c684dfdf..c17e4a920 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Convert-HTML-to-PDF-in-Azure-Function-App-Container.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Convert-HTML-to-PDF-in-Azure-Function-App-Container.md @@ -64,7 +64,7 @@ public IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post ms = new MemoryStream(); // Save and close the PDF document document.Save(ms); - document.Close(); + document.Close(true); } catch (Exception ex) { diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md index 6bd4ef707..756947697 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md @@ -73,10 +73,9 @@ blinkConverterSettings.ViewPortSize = new Syncfusion.Drawing.Size(1280, 0); htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); -//Create a filestream. -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/NuGet-Packages-Required.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/NuGet-Packages-Required.md index 67fd9278e..55439dfed 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/NuGet-Packages-Required.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/NuGet-Packages-Required.md @@ -108,5 +108,5 @@ ASP.NET MVC -N> 1. HTML to PDF conversion is not supported in Silverlight, Windows Phone, WinRT, Universal, Xamarin and UWP applications. +N> 1. HTML to PDF conversion is not supported in .NET MAUI, Xamarin, and UWP applications. N> 2. Starting with v21.1.XX, The package structure is changed if you reference Syncfusion® HTML to the PDF library from the NuGet feed. The Blink binaries paths are automatically added and do not need to add it manually. However, if you need to refer the blink binaries paths in your application manually, please use the BlinkPath in BlinkConverterSettings. Get the BlinkBinaries from the NuGet package runtime folder or get the binaries by installing the HTML converter installer. \ No newline at end of file diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/aspnet-mvc.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/aspnet-mvc.md index eaa385228..0883c3b6b 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/aspnet-mvc.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/aspnet-mvc.md @@ -67,6 +67,8 @@ PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); MemoryStream stream = new MemoryStream(); //Save the document to memory stream. document.Save(stream); +//Close the document +document.Close(true); return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "HTML-to-PDF.pdf"); {% endhighlight %} diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/blazor.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/blazor.md index c3c74428a..f278dc919 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/blazor.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/blazor.md @@ -59,6 +59,8 @@ public MemoryStream CreatePdf(string url) MemoryStream stream = new MemoryStream(); //Save the document to memory stream. document.Save(stream); + //Close the document + document.Close(true); return stream; } @@ -233,6 +235,8 @@ public MemoryStream CreatePdf(string url) MemoryStream stream = new MemoryStream(); //Save the document to memory stream. document.Save(stream); + //Close the document + document.Close(true); return stream; } @@ -430,6 +434,8 @@ public MemoryStream CreatePdf(string url) MemoryStream stream = new MemoryStream(); //Save the document to memory stream. document.Save(stream); + //Close the document + document.Close(true); return stream; } diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/features.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/features.md index e1e027228..07c2f4453 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/features.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/features.md @@ -137,9 +137,8 @@ using Syncfusion.HtmlConverter; HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); //Convert URL to Image Image image = htmlConverter.ConvertToImage("https://www.google.com"); -//Save and dispose the image file -image[0].Save("Output.jpg"); -image[0].Dispose(); +//Save the image. +File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData); {% endhighlight %} @@ -152,9 +151,8 @@ using Syncfusion.HtmlConverter; HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); //Convert URL to Image Image[] image = htmlConverter.ConvertToImage("https://www.google.com"); -//Save and dispose the image file -image[0].Save("Output.jpg"); -image[0].Dispose(); +//Save the image. +File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData); {% endhighlight %} @@ -167,10 +165,8 @@ Imports Syncfusion.HtmlConverter Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() 'Convert URL to Image Dim image As Image[] = htmlConverter.ConvertToImage("https://www.google.com") -'Save and dispose the image file -image[0].Save("Output.jpg") - -image[0].Dispose(True) +'Save the image. +File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData) {% endhighlight %} @@ -208,9 +204,8 @@ string baseUrl = @"C:/Temp/HTMLFiles/"; //Convert HTML string to Image Image image = htmlConverter.ConvertToImage(htmlText, baseUrl); -//Save and dispose the image file -image[0].Save("Output.jpg"); -image[0].Dispose(); +//Save the image. +File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData); {% endhighlight %} @@ -227,10 +222,9 @@ string htmlText = "\"Syncfusion EnableAutoScaling and GetHtmlBounds cannot be used simultaneously in the HTM ' Save the generated PDF document to a specified output file. document.Save("Output.pdf") ' Close the document. - document.Close() + document.Close(True) {% endhighlight %} @@ -2646,9 +2639,8 @@ The Blink HTML converter support adding the image background from HTML to Image htmlConverter.ConverterSettings = settings; //Convert HTML to Image. Image image = htmlConverter.ConvertToImage("Input.html"); - //Save and dispose the image file - image[0].Save("Output.png"); - image[0].Dispose(); + //Save the image. + File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData); {% endhighlight %} @@ -2667,9 +2659,8 @@ The Blink HTML converter support adding the image background from HTML to Image htmlConverter.ConverterSettings = settings ' Convert HTML to Image. Dim image As Image = htmlConverter.ConvertToImage("Input.html") - ' Save and dispose the image file - image[0].Save("Output.png") - image[0].Dispose() + ' Save the image. + File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData) {% endhighlight %} @@ -2702,9 +2693,8 @@ N> EnableAutoScaling and GetHtmlBounds cannot be used simultaneously in the HTML htmlConverter.ConverterSettings = blinkConverterSettings; // Convert the HTML file to an image Image image = htmlConverter.ConvertToImage(Path.GetFullPath("Input.html")); - //Save and dispose the image file - image[0].Save("Output.png"); - image[0].Dispose(); + //Save the image. + File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData); {% endhighlight %} @@ -2725,9 +2715,8 @@ N> EnableAutoScaling and GetHtmlBounds cannot be used simultaneously in the HTML htmlConverter.ConverterSettings = blinkConverterSettings ' Convert the HTML file to an image Dim image As Image = htmlConverter.ConvertToImage(Path.GetFullPath("Input.html")) - ' Save and dispose the image file - image[0].Save("Output.png") - image[0].Dispose() + ' Save the image + File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData) {% endhighlight %} diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/linux.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/linux.md index 48fe7b996..96002356d 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/linux.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/linux.md @@ -63,14 +63,12 @@ Step 4: Add code samples in Program.cs file to convert HTML to PDF document usi //Initialize HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); -BlinkConverterSettings settings = new BlinkConverterSettings(); -//Assign Blink settings to the HTML converter. -htmlConverter.ConverterSettings = settings; + //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close a PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/mac.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/mac.md index 825611765..2ff798b57 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/mac.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/mac.md @@ -74,6 +74,8 @@ public IActionResult ExportToPDF() PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); MemoryStream stream = new MemoryStream(); document.Save(stream); + //Close the document + document.Close(true); //Download the PDF document in the browser return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "HTML-to-PDF.pdf"); } @@ -155,6 +157,8 @@ public IActionResult ExportToPDF() PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); MemoryStream stream = new MemoryStream(); document.Save(stream); + //Close the document + document.Close(true); //Download the PDF document in the browser return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "HTML-to-PDF.pdf"); } diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/net-core.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/net-core.md index 110cfa656..653bfe36f 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/net-core.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/net-core.md @@ -79,7 +79,7 @@ PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); MemoryStream stream = new MemoryStream(); //Save and close the document. document.Save(stream); -document.Close(); +document.Close(true); return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "HTML-to-PDF.pdf"); {% endhighlight %} @@ -163,7 +163,7 @@ PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); MemoryStream stream = new MemoryStream(); //Save and close the document. document.Save(stream); -document.Close(); +document.Close(true); return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "HTML-to-PDF.pdf"); {% endhighlight %} @@ -261,7 +261,7 @@ PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); MemoryStream stream = new MemoryStream(); //Save and close the document. document.Save(stream); -document.Close(); +document.Close(true); return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "HTML-to-PDF.pdf"); {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Document-Conversions.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Document-Conversions.md index 97108b307..5e3be7eb7 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Document-Conversions.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Document-Conversions.md @@ -1267,43 +1267,60 @@ You can download a complete working sample from [GitHub](https://github.com/Sync N> To know more about PdfToImageConverter and features it provides, please refer to [PdfToImageConverter](https://help.syncfusion.com/document-processing/pdf/conversions/pdf-to-image/net/convert-pdf-file-to-image-in-asp-net-core) -## HTML to MHTML +## HTML to PDF -The [HTML to PDF converter library](https://www.syncfusion.com/document-processing/pdf-framework/net/html-to-pdf) supports converting the webpage to an MHTML file. Please refer to the following code example. +The [HTML to PDF converter library](https://www.syncfusion.com/document-processing/pdf-framework/net/html-to-pdf) supports converting web pages and HTML content into high-quality PDF documents. -*HTML to PDF Features:* [https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features) - -*Troubleshooting:* [https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/troubleshooting](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/troubleshooting) +**Learn more about the features supported in HTML to PDF conversion here**: [HTML to PDF Features](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features) + +**Check out the troubleshooting guide here**: [Troubleshooting](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/troubleshooting) {% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Convert-website-URL-to-PDF-document/.NET/Convert-website-URL-to-PDF-document/Program.cs, 300" %} -//PDF doesn't support converting HTML to MHTML C#.NET Cross platforms. +//Initialize HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.google.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -//Initialize HTML to PDF converter +//Initialize HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); -//Convert URL to MHTML -htmlConverter.ConvertToMhtml("http://www.syncfusion.com", "sample.mhtml"); +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.google.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Initialize HTML to PDF converter -Dim htmlConverter As New HtmlToPdfConverter() -'Convert URL to MHTML -htmlConverter.ConvertToMhtml("http://www.syncfusion.com", "sample.mhtml") +' Initialize HTML to PDF converter +Dim htmlConverter As New HtmlToPdfConverter() + +' Convert HTML to PDF +Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") + +' Save and close the PDF document +document.Save("Output.pdf") +document.Close(True) + {% endhighlight %} {% endtabs %} -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Document%20conversion/Convert-HTML-to-MHTML). +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Convert-website-URL-to-PDF-document). ## SVG to PDF From 518af8fb3981db33688a3f49b44cd7e414e815d6 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Fri, 3 Oct 2025 18:56:11 +0530 Subject: [PATCH 8/9] 985014-ug: Added save changes. --- Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md index 29a0ec508..70695a8e2 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md @@ -214,10 +214,9 @@ blinkConverterSettings.ViewPortSize = new Syncfusion.Drawing.Size(1280, 0); htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); -//Create a filestream. -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + //Save and close the PDF document. -document.Save(fileStream); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} From a3ab071b92fd29afd2318c73d285edd0a4712391 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Fri, 3 Oct 2025 19:50:20 +0530 Subject: [PATCH 9/9] 985014-ug: Resolved CI failures. --- .../PDF/Conversions/HTML-To-PDF/NET/mac.md | 2 - .../Converting-HTML-to-PDF-in-ASP-NET-Core.md | 78 ----- ...Converting-HTML-to-PDF-in-Windows-Forms.md | 105 ------ .../PDF-Library/NET/Converting-HTML-to-PDF.md | 320 ------------------ 4 files changed, 505 deletions(-) delete mode 100644 Document-Processing/PDF/PDF-Library/NET/Converting-HTML-to-PDF-in-ASP-NET-Core.md delete mode 100644 Document-Processing/PDF/PDF-Library/NET/Converting-HTML-to-PDF-in-Windows-Forms.md delete mode 100644 Document-Processing/PDF/PDF-Library/NET/Converting-HTML-to-PDF.md diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/mac.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/mac.md index 2ff798b57..7d311ea24 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/mac.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/mac.md @@ -85,8 +85,6 @@ public IActionResult ExportToPDF() Step 8: Right click the project and select Build. ![Build project](htmlconversion_images/mac_step5.png) -N> Once the build succeeded, unzip the chromium.app file in bin folder (bin-> Debug-> net6.0-> runtimes-> osx-> native-> Chromium.app)` - Step 9: Run the application. ![Run application](htmlconversion_images/mac_step6.png) diff --git a/Document-Processing/PDF/PDF-Library/NET/Converting-HTML-to-PDF-in-ASP-NET-Core.md b/Document-Processing/PDF/PDF-Library/NET/Converting-HTML-to-PDF-in-ASP-NET-Core.md deleted file mode 100644 index 3bbe65b4b..000000000 --- a/Document-Processing/PDF/PDF-Library/NET/Converting-HTML-to-PDF-in-ASP-NET-Core.md +++ /dev/null @@ -1,78 +0,0 @@ ---- -title: Convert a HTML to PDF file in ASP.NET Core | Syncfusion -description: Learn how to convert a HTML to PDF file in ASP.NET Core with easy steps using Syncfusion .NET Core HTML Converter library. -platform: document-processing -control: PDF -documentation: UG -keywords: Assemblies ---- - -# Convert HTML to PDF file in ASP.NET Core - -The Syncfusion® HTML to PDF converter is a .NET Core library used to convert HTML or web pages to PDF document. Using this library you can convert HTML to PDF in ASP.NET Core application. - -To include the HTML Converter library into your ASP.NET Core application, please refer to the [NuGet Packages Required](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/overview#nuget-packages-required-recommended) or [Assemblies Required](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/overview#assemblies-required) documentation. - -## Steps to convert HTML to PDF document using Blink in ASP.NET Core - -Create a new C# ASP.NET Core Web Application project. -![Convert_HtmlToPdf_net_core1](Asp.Net.Core_images/html-to-pdf-conversion1.png) - -Set the project name, location and .NET version for your ASP.NET Core application. -![Convert_HtmlToPdf_net_core2](Asp.Net.Core_images/html-to-pdf-conversion2.png) - -![Convert_HtmlToPdf_net_core3](Asp.Net.Core_images/html-to-pdf-conversion3.png) - -Install the [Syncfusion.HtmlToPdfConverter.Net.Windows](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Windows) as a reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org/). -![Convert_HtmlToPdf_net_core4](Asp.Net.Core_images/html-to-pdf-conversion4.png) - -A default controller with name HomeController.cs gets added on creation of ASP.NET Core project. Include the following namespaces in that HomeController.cs file. - -{% highlight c# tabtitle="C#" %} - -using Syncfusion.HtmlConverter; -using Syncfusion.Pdf; - -{% endhighlight %} - -A default action method named Index will be present in HomeController.cs. Right click on Index method and select Go To View where you will be directed to its associated view page Index.cshtml. - -Add a new button in the Index.cshtml as shown below. - -{% highlight c# tabtitle="C#" %} - -@{Html.BeginForm("ExportToPDF", "Home", FormMethod.Post); -{ -
      - -
      -} -Html.EndForm(); -} -{% endhighlight %} - -Add a new action method ExportToPDF in HomeController.cs and include the below code snippet to convert HTML to PDF file and download it. - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -//Convert URL to PDF document -PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); - -//Create memory stream -MemoryStream stream = new MemoryStream(); - -//Save the document -document.Save(stream); - -return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "HTML-to-PDF.pdf"); - -{% endhighlight %} - -A complete working sample can be downloaded from [HtmlToPDFSample.zip](https://www.syncfusion.com/downloads/support/directtrac/general/ze/HTML-To-PDF-sample840126948). - -By executing the program, you will get the PDF document as follows. -![Convert_WebKit6](Asp.Net.Core_images/htmltopdfoutput.png) - diff --git a/Document-Processing/PDF/PDF-Library/NET/Converting-HTML-to-PDF-in-Windows-Forms.md b/Document-Processing/PDF/PDF-Library/NET/Converting-HTML-to-PDF-in-Windows-Forms.md deleted file mode 100644 index e4c6fa146..000000000 --- a/Document-Processing/PDF/PDF-Library/NET/Converting-HTML-to-PDF-in-Windows-Forms.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -title: Convert a HTML to PDF file in Windows-Forms | Syncfusion -description: Learn how to convert a HTML to PDF file in Windows-Forms with easy steps using Syncfusion .NET HTML converter library. -platform: document-processing -control: PDF -documentation: UG -keywords: Assemblies ---- - -# Convert HTML to PDF file in Windows Forms - -The [Syncfusion® HTML to PDF converter](https://www.syncfusion.com/document-processing/pdf-framework/net/html-to-pdf) is a .NET library used to convert HTML or web pages to PDF document in Windows Forms application. - -To include the .NET HTML to PDF converter library into your Windows Forms application, please refer to the [NuGet Package Required](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/overview#nuget-packages-required-recommended) or [Assemblies Required](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/overview#assemblies-required) documentation. - -## Steps to convert Html to PDF document in Windows Forms - -Step 1: Create a new Windows Forms application project. -Convert HTMLToPDF Windows Forms Step1 -In project configuration window, name your project and select Create. -Convert HTMLToPDF Windows Forms Step2 - -Step 2: Install the [Syncfusion.HtmlToPdfConverter.WinForms](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.WinForms) NuGet package as a reference to your WinForms application [NuGet.org](https://www.nuget.org/). -Convert HTMLToPDF Windows Forms Step3 - -Step 3: Add the following namespaces into **Form1.Designer.cs** file. - -{% highlight c# tabtitle="C#" %} - -using System; -using System.Windows.Forms; - -{% endhighlight %} - -Step 4: Add a new button in **Form1.Designer.cs** to convert HTML to PDF document as follows. - -{% highlight c# tabtitle="C#" %} - -private Button btnCreate; -private Label label; -private void InitializeComponent() -{ - btnCreate = new Button(); - label = new Label(); - - //Label - label.Location = new System.Drawing.Point(0, 40); - label.Size = new System.Drawing.Size(426, 35); - label.Text = "Click the button to convert Html to PDF file"; - label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - - //Button - btnCreate.Location = new System.Drawing.Point(180, 110); - btnCreate.Size = new System.Drawing.Size(85, 26); - btnCreate.Text = "Convert Html to PDF"; - btnCreate.Click += new EventHandler(btnCreate_Click); - - //Create PDF - ClientSize = new System.Drawing.Size(450, 150); - Controls.Add(label); - Controls.Add(btnCreate); - Text = "Convert Html to PDF"; -} - -{% endhighlight %} - -Step 5: Include the following namespaces in the **Form1.cs** file. - -{% highlight c# tabtitle="C#" %} - -using Syncfusion.HtmlConverter; -using Syncfusion.Pdf; -using System; - -{% endhighlight %} - -Step 6: Create the btnCreate_Click event and add the following code in btnCreate_Click to convert HTML to PDF document using [Convert](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html#Syncfusion_HtmlConverter_HtmlToPdfConverter_Convert_System_String_) method in [HtmlToPdfConverter](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html) class. The HTML content will be scaled based on the given [ViewPortSize](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_ViewPortSize) property of [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class. - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML to PDF converter. -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); -BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); -//Set Blink viewport size. -blinkConverterSettings.ViewPortSize = new System.Drawing.Size(1280, 0); -//Assign Blink converter settings to HTML converter. -htmlConverter.ConverterSettings = blinkConverterSettings; -//Convert URL to PDF document. -PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); -//Create file stream. -FileStream stream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew); -//Save the document into stream. -document.Save(stream); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Close the document. -document.Close(); -stream.Dispose(); - -{% endhighlight %} - -By executing the program, you will get the PDF document as follows. -Convert HTMLToPDF Windows Forms output - -A complete working sample can be downloaded from [Github](https://github.com/SyncfusionExamples/html-to-pdf-csharp-examples/tree/master/Windows%20Forms). diff --git a/Document-Processing/PDF/PDF-Library/NET/Converting-HTML-to-PDF.md b/Document-Processing/PDF/PDF-Library/NET/Converting-HTML-to-PDF.md deleted file mode 100644 index c565fc483..000000000 --- a/Document-Processing/PDF/PDF-Library/NET/Converting-HTML-to-PDF.md +++ /dev/null @@ -1,320 +0,0 @@ ---- -title: Converting HTML to PDF | Syncfusion -description: Learn how to convert HTML to PDF using 2 different rendering engines (Blink and IE) with various features like TOC, partial web page to PDF etc. -platform: document-processing -control: PDF -documentation: UG ---- -# Converting HTML to PDF - -The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage. - -Syncfusion® HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS. - -## Key features for HTML Converter - -* Converts any [webpage to PDF](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#url-to-pdf). -* Converts any raw [HTML string to PDF](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#html-string-to-pdf). -* Converts [HTML form to fillable PDF form](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#html-form-to-pdf-form). -* Automatically creates [Table of Contents](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#table-of-contents). -* Automatically creates [bookmark hierarchy](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#bookmarks). -* Converts only a [part of the web page to PDF](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#partial-webpage-to-pdf). -* Supports PDF header and PDF footer. -* Repeats HTML table header and footer in PDF. -* Supports HTML5, CSS3, SVG, and Web fonts. -* Converts any [HTML to an image](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#url-to-image). -* Converts any [SVG to image](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#url-to-image). -* Supports accessing HTML pages using both [HTTP POST and GET](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#http-get-and-post) methods. -* Supports [HTTP cookies](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#form-authentication). -* Supports [cookies-based form authentication](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#form-authentication). -* Thread safe. -* Supports internal and external [hyperlinks](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#hyperlinks). -* Sets document properties, page settings, security, viewer preferences, and more. -* Protects PDF document with password and permission. -* Compatible with .NET Framework 4.5 and above. -* Compatible with .NET Core 2.0 and above. - -## Install HTML to PDF .NET library to your project - -Include the HTML to PDF converter in your project using two approaches. -* NuGet packages (Recommended) -* Assemblies. - -### NuGet Packages Required (Recommended) - -Directly install the NuGet packages to your .NET application from [nuget.org](https://www.nuget.org/). - -N> The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement. - - - - - - - - - - - - - - - - - - - - - - - - -
      Platform(s)NuGet Package
      -(.NET Core, .NET 5, .NET 6) Windows - -{{'[Syncfusion.HtmlToPdfConverter.Net.Windows.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Windows/)'| markdownify }} -
      -(.NET Core, .NET 5, .NET 6) Linux - -{{'[Syncfusion.HtmlToPdfConverter.Net.Linux.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Linux/)'| markdownify }} -
      -(.NET Core, .NET 5, .NET 6) Mac - -{{'[Syncfusion.HtmlToPdfConverter.Net.Mac.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Mac/)'| markdownify }} -
      -(.NET Core, .NET 5, .NET 6) AWS - -{{'[Syncfusion.HtmlToPdfConverter.Net.Aws.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Aws/)'| markdownify }} -
      - -Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion® libraries or components, use the HTML to PDF converter library with the same platform packages. - - - - - - - - - - - - - - - - - - - - - - - - -
      Platform(s)NuGet Package
      -Windows Forms - -{{'[Syncfusion.HtmlToPdfConverter.WinForms.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.WinForms/)'| markdownify }} -
      -WPF - -{{'[Syncfusion.HtmlToPdfConverter.Wpf.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Wpf/)'| markdownify }} -
      -ASP.NET - -{{'[Syncfusion.HtmlToPdfConverter.AspNet.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.AspNet/)'| markdownify }} -
      -ASP.NET MVC - -{{'[Syncfusion.HtmlToPdfConverter.AspNet.Mvc5.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.AspNet.Mvc5/)'| markdownify }} -
      - -### Assemblies Required - -Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for [Windows](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/advanced-installation#windows), [Linux](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/advanced-installation#linux), and [Mac](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/advanced-installation#mac), respectively. Please refer to the [advanced installation](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/advanced-installation) steps for more details. - - - - - - - - - - - - - - -
      -Platforms -Assemblies -
      -WinForms -WPF -ASP.NET -ASP.NET MVC - -
        -
      • Syncfusion.Compression.Base.dll
      • -
      • Syncfusion.Pdf.Base.dll
      • -
      • Syncfusion.HtmlConverter.Base.dll
      • -
      • Newtonsoft.Json package (v13.0.1 or above)
      • -
      -
      -.NET/.NET Core -Blazor - -
        -
      • Syncfusion.Compression.Portable.dll
      • -
      • Syncfusion.Pdf.Portable.dll
      • -
      • Syncfusion.HtmlConverter.Portable.dll
      • -
      • Newtonsoft.Json package (v13.0.1 or above)
      • -
      -
      - -## Get Started with HTML to PDF conversion - -### Convert HTML to PDF in C# - -Integrating HTML to PDF converter library in any .NET application is simple. Please refer to the following steps to include HTML to PDF conversion in your application. - -Steps to convert HTML to PDF in .NET application - -Step 1: Create a new .NET console application. -Create .net core console sample - -Select target .net core version - -Step 2: Install [Syncfusion.HtmlToPdfConverter.Net.Windows](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Windows) NuGet package as a reference to your .NET application from [NuGet.org](https://www.nuget.org/). -Install HTML to PDF converter .NET package - -Step 3: Include the following namespace in your class file. - -{% highlight c# tabtitle="C#" %} - -using Syncfusion.Pdf; -using Syncfusion.HtmlConverter; - -{% endhighlight %} - -Step 4: Use the following code sample to convert the URL to PDF in the program.cs. - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML to PDF converter. -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); -BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); -//Set Blink viewport size. -blinkConverterSettings.ViewPortSize = new Syncfusion.Drawing.Size(1280, 0); -//Assign Blink converter settings to HTML converter. -htmlConverter.ConverterSettings = blinkConverterSettings; -//Convert URL to PDF document. -PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); -//Create a filestream. -FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); -//Save and close the PDF document. -document.Save(fileStream); -document.Close(true); - -{% endhighlight %} - -{% endtabs %} - -By executing the program, you will get the PDF document as follows. -htmltopdfoutput - -A complete working sample can be downloaded from [Github](https://github.com/SyncfusionExamples/html-to-pdf-csharp-examples/tree/master/.NET). - -### Convert HTML to PDF in Linux - -HTML to PDF converter .NET library supports conversion in Linux. Refer to [this](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/linux) section for more information about HTML to PDF conversion in Linux. - -### Convert HTML to PDF in Docker - -HTML to PDF converter .NET library supports conversion in Docker. Refer to [this](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/docker) section for more information about HTML to PDF conversion in Docker. - -### Convert HTML to PDF in Mac - -HTML to PDF converter .NET library supports conversion in Mac. Refer to [this](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/mac) section for more information about HTML to PDF conversion in Mac. - -### Convert HTML to PDF in ASP.NET Core - -HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to [this](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/net-core) section for more information about HTML to PDF conversion in ASP.NET Core. - -### Convert HTML to PDF in ASP.NET MVC -HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to [this](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/aspnet-mvc) section for more information about HTML to PDF conversion in ASP.NET MVC. - -### Convert HTML to PDF in Blazor -HTML to PDF converter .NET library supports conversion in Blazor. Refer to [this](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/blazor) section for more information about HTML to PDF conversion in Blazor. - -### Convert HTML to PDF in Azure -HTML to PDF converter .NET library supports conversion in Azure. Refer to [this](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/azure) section for more information about HTML to PDF conversion in Azure. - -### Convert HTML to PDF in AWS -HTML to PDF converter .NET library supports conversion in AWS. Refer to [this](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/aws) section for more information about HTML to PDF conversion in AWS. - -## Features - -Refer to [this](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features) section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section. - -## Troubleshooting and FAQ - -<<<<<<< HEAD -Refer to [this](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/troubleshooting) section for troubleshooting HTML to PDF conversion failures and frequently asked questions. -======= - -## Steps to disable IE warning while performing HTML To PDF using the IE rendering engine - -By default, the PDF document generated with the IE rendering engine comes with the following warning message. - -IEWarning -Please refer to the below code snippet to use the DisableIEWarning API to remove the default IE warning from the PDF document. - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize the HTML to PDF converter - HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.IE); -IEConverterSettings settings = new IEConverterSettings(); -//Disable Default IE warning message. -settings.DisableIEWarning = true; -//Assign IE settings to HTML converter -htmlConverter.ConverterSettings = settings; -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save and close the PDF document -document.Save("Output.pdf"); -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} -'Initialize the HTML to PDF converter -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.IE) -Dim settings As New IEConverterSettings() -'Disable Default IE Warning Message -settings.DisableIEWarning = true -'Assign IE settings to HTML converter -htmlConverter.ConverterSettings = settings -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") - -'Save and close the PDF document -document.Save("Output.pdf") -document.Close(True) - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} -//Currently, IE rendering engine does not support conversion in .NET Core platform -{% endhighlight %} - -{% endtabs %} - -N>Please try our [Blink](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/net-core) engine to improve the quality and accuracy of the HTML to PDF conversion.