diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/advanced-installation.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/advanced-installation.md index d1b94966ce..a88f4b5f44 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/advanced-installation.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/advanced-installation.md @@ -1,5 +1,5 @@ --- -title: Advanced installation of HTML to PDF in .NET PDF Library | Syncfusion® +title: Advanced installation of HTML to PDF in .NET PDF Library | Syncfusion description: Explore our guide on how to convert HTML to PDF using the Blink rendering engine with various features like TOC, partial web page to PDF, and more. platform: document-processing control: PDF @@ -8,9 +8,16 @@ documentation: UG # Advanced Installation -You can download and install the HTML to PDF converter for Windows, Linux and Mac platforms. +The [HTML to PDF Converter](https://www.syncfusion.com/document-sdk/net-pdf-library/html-to-pdf) uses the Blink rendering engine to convert HTML, web pages, and web content into PDF documents. The converter is available for Windows, Linux, and macOS. -[https://www.syncfusion.com/account/downloads](https://www.syncfusion.com/account/downloads ) +**Prerequisites:** +Before installing the HTML to PDF Converter: + +* Ensure that you have a valid Syncfusion license. +* Verify that your development environment supports the version of Syncfusion® PDF Library you are using. +* Download the latest installer package from the Syncfusion Downloads page: + +[https://www.syncfusion.com/account/downloads](https://www.syncfusion.com/account/downloads) ## Windows 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 462cbcf08a..3e3b7c195b 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/features.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/features.md @@ -1,16 +1,20 @@ --- title: HTML to PDF converter features in .NET PDF Library | Syncfusion -description: Learn how to convert HTML to PDF using Blink rendering engines (Blink, WebKit and IE) with various features like TOC, partial web page to PDF etc. +description: Learn how to convert HTML to PDF using the Blink rendering engine with features like table of contents, partial page conversion, and more. platform: document-processing control: PDF documentation: UG --- -# HTML converter Features +# HTML converter features + +The Syncfusion HTML to PDF converter uses the Blink rendering engine (based on Chromium) to convert HTML pages, HTML strings, and SVG content into high-quality PDF documents and images. It supports a wide range of features including authentication, headers and footers, JavaScript execution, accessibility, and more. + +N> The Blink rendering engine is fully supported in both .NET Core (cross-platform) and .NET Framework (Windows-specific) applications. All examples in this document include code for both targets. ## URL to PDF -To convert website URL or local HTML file 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. refer to the following code example. +To convert a website URL or local HTML file to a PDF document, use the [Convert](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html#Syncfusion_HtmlConverter_HtmlToPdfConverter_Convert_System_String_) method of the [HtmlToPdfConverter](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html) class. Refer to the following code example. {% tabs %} @@ -68,15 +72,15 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## HTML String to PDF -The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL. +The HTML to PDF converter supports converting an HTML string to a PDF. While converting an HTML string to a PDF, the converter provides an option to specify the base URL. -baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string. +**baseURL:** Path of the resources (images, style sheets, scripts, etc.) used in the input HTML string. -For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image. +For the following HTML string, the `baseURL` will be the path of the `syncfusion_logo.gif` image. -For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows. +For example, if the above image is in the `C:/Temp/HTMLFiles/syncfusion_logo.gif` location, then the `baseURL` will be as follows. -baseURL: C:/Temp/HTMLFiles/ +**baseURL:** `C:/Temp/HTMLFiles/` To convert the HTML string to PDF using [Convert](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html#Syncfusion_HtmlConverter_HtmlToPdfConverter_Convert_System_String_System_String_) method, refer to the following code example. @@ -150,7 +154,7 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## URL to Image -To convert website URL or local HTML file to Image using [ConvertToImage](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html#Syncfusion_HtmlConverter_HtmlToPdfConverter_ConvertToImage_System_String_) method, refer to the following code example. +To convert a website URL or local HTML file to an image, use the [ConvertToImage](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html#Syncfusion_HtmlConverter_HtmlToPdfConverter_ConvertToImage_System_String_) method. Refer to the following code example. {% tabs %} @@ -170,7 +174,7 @@ File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData); {% highlight c# tabtitle="C# [Windows-specific]" %} -using Syncfusion.Drawing; +using System.Drawing; using Syncfusion.HtmlConverter; //Initialize HTML to PDF converter @@ -190,9 +194,9 @@ Imports Syncfusion.HtmlConverter 'Initialize HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() 'Convert URL to Image -Dim image As Image[] = htmlConverter.ConvertToImage("https://www.google.com") +Dim image As Image() = htmlConverter.ConvertToImage("https://www.google.com") 'Save the image. -File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData) +File.WriteAllBytes(Path.GetFullPath("Output/Output.jpg"), image.ImageData) {% endhighlight %} @@ -202,15 +206,15 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## HTML String to Image -The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL. +The Blink rendering engine supports converting an HTML string to an image. While converting an HTML string to an image, the converter provides an option to specify the base URL. -baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string. +**baseURL:** Path of the resources (images, style sheets, scripts, etc.) used in the input HTML string. -For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image. +For the following HTML string, the `baseURL` will be the path of the `syncfusion_logo.gif` image. -For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows. +For example, if the above image is in the `C:/Temp/HTMLFiles/syncfusion_logo.gif` location, then the `baseURL` will be as follows. -baseURL: C:/Temp/HTMLFiles/ +**baseURL:** `C:/Temp/HTMLFiles/` To convert the HTML string to Image using [ConvertToImage](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html#Syncfusion_HtmlConverter_HtmlToPdfConverter_ConvertToImage_System_String_System_String_) method, refer to the following code example. @@ -267,9 +271,9 @@ Dim htmlText As String = " Print [MediaType](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_MediaType) MediaType enables the repeat html table header and footer support on every PDF page. +N> The [MediaType](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_MediaType) property set to `Print` enables the HTML table header and footer to be repeated on every PDF page. ## HTML Form to PDF Form -Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the [EnableForm](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_EnableForm) property. To convert HTML form to PDF form, refer to the following code example. +The Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the [EnableForm](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_EnableForm) property. To convert an HTML form to a PDF form, refer to the following code example. {% tabs %} @@ -1152,7 +1156,7 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## Windows authentication -The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the [Username](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_Username) and [Password](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_Password) property in [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class. Refer to the following code example. +The webpage you want to convert may be protected with Windows authentication. The Blink rendering engine supports converting Windows-authenticated webpages to PDF documents by setting the [Username](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_Username) and [Password](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_Password) properties in the [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class. Refer to the following code example. {% tabs %} @@ -1230,7 +1234,7 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## Form authentication -The Blink HTML converter provides support for form authentication by using [Cookies](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_Cookies) property in [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example. +The Blink HTML converter supports form authentication by using the [Cookies](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_Cookies) property in the [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class. The cookies are sent to the web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example. {% tabs %} @@ -1244,8 +1248,8 @@ HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); // Add cookies as name and value pair -blinkConverterSettings.Cookies.Add("CookieName1", " CookieValue1"); -blinkConverterSettings.Cookies.Add("CookieName2", " CookieValue2"); +blinkConverterSettings.Cookies.Add("CookieName1", "CookieValue1"); +blinkConverterSettings.Cookies.Add("CookieName2", "CookieValue2"); //Assign Blink converter settings to HTML converter htmlConverter.ConverterSettings = blinkConverterSettings; @@ -1268,8 +1272,8 @@ HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); // Add cookies as name and value pair -blinkConverterSettings.Cookies.Add("CookieName1", " CookieValue1"); -blinkConverterSettings.Cookies.Add("CookieName2", " CookieValue2"); +blinkConverterSettings.Cookies.Add("CookieName1", "CookieValue1"); +blinkConverterSettings.Cookies.Add("CookieName2", "CookieValue2"); //Assign Blink converter settings to HTML converter htmlConverter.ConverterSettings = blinkConverterSettings; @@ -1291,9 +1295,9 @@ Imports Syncfusion.Pdf Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() Dim blinkConverterSettings As BlinkConverterSettings = New BlinkConverterSettings() -'Add cookies -blinkConverterSettings.Cookies.Add("Name1", "Value1") -blinkConverterSettings.Cookies.Add("Name2", "Value2") +'Add cookies as name and value pair +blinkConverterSettings.Cookies.Add("CookieName1", "CookieValue1") +blinkConverterSettings.Cookies.Add("CookieName2", "CookieValue2") 'Assign Blink converter settings to HTML converter htmlConverter.ConverterSettings = blinkConverterSettings @@ -1311,7 +1315,7 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## Token-based authentication -The Blink HTML converter supports token-based authentication by using the [HttpRequestHeaders](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_HttpRequestHeaders) property in [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example. +The Blink HTML converter supports token-based authentication by using the [HttpRequestHeaders](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_HttpRequestHeaders) property in the [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class. The token values are sent to the web server when the HTML page is requested. Refer to the following code example. {% tabs %} @@ -1367,10 +1371,10 @@ document.Close(true); Imports Syncfusion.HtmlConverter Imports Syncfusion.Pdf -'Initialize HTML to PDF converter +'Initialize HTML to PDF converter Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() -Dim settings As BlinkConverterSettings = New BlinkConverterSettings +Dim settings As BlinkConverterSettings = New BlinkConverterSettings() 'Add a bearer token to login a webpage settings.HttpRequestHeaders.Add("Authorization", "bearer <>") 'Assign Blink settings to HTML converter @@ -1378,9 +1382,9 @@ htmlConverter.ConverterSettings = settings 'Convert URL to PDF Dim document As PdfDocument = htmlConverter.Convert("https://www.example.com") -'Save and close the PDF document +'Save and close the PDF document document.Save("Output.pdf") -document.Close(true) +document.Close(True) {% endhighlight %} @@ -1390,9 +1394,9 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## Offline conversion -The Blink HTML converter supports converting HTML to PDF in offline mode using [EnableOfflineMode](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_EnableOfflineMode) property in [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection. +The Blink HTML converter supports converting HTML to PDF in offline mode using the [EnableOfflineMode](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_EnableOfflineMode) property in the [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class. When converting HTML to PDF in offline mode, the converter does not access resources from the internet. This can improve performance on slow internet connections. -N> If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online. +N> If an online URL is converted in offline mode, the converter generates an empty PDF, because it will not try to load any resource from the internet. Refer to the following code snippet. @@ -1473,7 +1477,8 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## HTTP GET and POST -The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the [HttpPostFields](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_HttpPostFields) property. +The Blink HTML converter supports transmitting parameters to a webpage. There are two methods to access a webpage: GET and POST. By default, Blink uses the GET method. With the HTTP GET method, the parameters can be passed in the query string. With the POST method, the parameters can be passed by using the [HttpPostFields](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_HttpPostFields) property. + Refer to the following code snippet to access a webpage using HTTP POST. {% tabs %} @@ -1631,13 +1636,13 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## System proxy -By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings: +By default, the Blink rendering engine uses the system proxy settings for converting HTML to PDF. If a proxy server is configured on the system, the rendering engine automatically uses the same settings for the conversion. Follow the steps below to set the system proxy settings: -1. Control Panel > Network and Internet > Internet Options. -2. From Internet properties window, open LAN settings under connections tab. -3. Then, set proxy server address and port in LAN settings window. +1.Control Panel > Network and Internet > Internet Options. +2.From the Internet Properties window, open **LAN settings** under the **Connections** tab. +3.Then, set the proxy server address and port in the LAN settings window. -Please refer below screenshots: +**Please refer to the screenshots below:** Manual proxy @@ -1727,8 +1732,7 @@ document.Close(True) ## Viewport -Adjusting the HTML content size in PDF is possible by using the [ViewPortSize](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_ViewPortSize) property of Blink HTML converter. -Refer to the following code snippet to adjust Blink viewport. +The HTML content size in the PDF can be adjusted by using the [ViewPortSize](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_ViewPortSize) property of the Blink HTML converter. Refer to the following code snippet to adjust the Blink viewport. N> The HTML converter internally uses the viewport size in points. @@ -1760,7 +1764,7 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} -using Syncfusion.Drawing; +using System.Drawing; using Syncfusion.HtmlConverter; using Syncfusion.Pdf; @@ -1858,7 +1862,7 @@ Imports Syncfusion.Pdf Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() 'Convert Partial webpage to PDF -Dim document As PdfDocument = htmlConverter. ConvertPartialHtml("input.html", "pic") +Dim document As PdfDocument = htmlConverter.ConvertPartialHtml("input.html", "pic") 'Save and close the PDF document document.Save("Output.pdf") document.Close(True) @@ -1870,13 +1874,14 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## HTML to single PDF page -By using this [SinglePageLayout](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_SinglePageLayout) property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default. +By using the [SinglePageLayout](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_SinglePageLayout) property, you can render the entire HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature. This feature is disabled by default. - 1. FitWidth - 2. FitHeight +1. **FitWidth** +2. **FitHeight** -Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option. -Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option. +**FitWidth option:** Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. The PDF page width remains constant for this option. + +**FitHeight option:** Using this option, the HTML converter scales the HTML content and PDF page width to render the whole HTML content within the height. The PDF page height remains constant for this option. Refer to the following code snippet. @@ -1954,12 +1959,13 @@ document.Close(True) ## Layout Result -Getting height of the HTML content in PDF document is possible by using the [PdfLayoutResult](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Graphics.PdfLayoutResult.html) class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example. +Getting the height of the HTML content in the PDF document is possible by using the [PdfLayoutResult](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Graphics.PdfLayoutResult.html) class. Using this result, you can add content after converting HTML to PDF. Refer to the following code example. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.Drawing; using Syncfusion.HtmlConverter; using Syncfusion.Pdf; @@ -1981,6 +1987,7 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; using Syncfusion.HtmlConverter; using Syncfusion.Pdf; @@ -2002,6 +2009,7 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing Imports Syncfusion.HtmlConverter Imports Syncfusion.Pdf @@ -2022,12 +2030,12 @@ document.Close(True) {% endtabs %} -## Windows status +## Window status -Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using [WindowStatus ](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_WindowStatus) property. +The window status can be used instead of the additional delay. With the additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using the [WindowStatus](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_WindowStatus) property. N> This feature requires changes in the HTML file. -N> If windows status does not match in code and HTML, then the converter will meet with deadlock. +N> If the window status does not match between the code and the HTML, then the converter will encounter a deadlock. Refer to the following code snippet. @@ -2314,7 +2322,7 @@ document.Close(true); using Syncfusion.HtmlConverter; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf; -using Syncfusion.Drawing; +using System.Drawing; //Initialize HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -2384,8 +2392,8 @@ Dim compositeField As PdfCompositeField = New PdfCompositeField(font, PdfBrushes compositeField.Draw(footer.Graphics, PointF.Empty) 'Assign the footer element to PdfFooter of Blink converter settings. blinkConverterSettings.PdfFooter = footer -'Set Blink viewport size. -blinkConverterSettings.ViewPortSize = new Size(1024, 0) +'Set Blink viewport size. +blinkConverterSettings.ViewPortSize = New Size(1024, 0) 'Assign Blink converter settings to HTML converter. htmlConverter.ConverterSettings = blinkConverterSettings 'Convert URL to PDF document. @@ -2664,12 +2672,13 @@ N> The HtmlHeader and HtmlFooter properties have certain limitatio ## Inject custom CSS -The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the 'Css' property of the [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class +The Blink rendering engine supports the injection of custom CSS to be applied to an HTML string or a URL before rendering it into a PDF document using the [Css](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_Css) property of the [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class. {% tabs %} {% 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; @@ -2718,9 +2727,9 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing Imports Syncfusion.HtmlConverter Imports Syncfusion.Pdf -Imports System.Drawing 'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() @@ -2729,14 +2738,14 @@ Dim blinkConverterSettings As BlinkConverterSettings = New BlinkConverterSetting blinkConverterSettings.ViewPortSize = New Size(1280, 0) blinkConverterSettings.Margin.All = 30 'Set custom CSS -blinkConverterSettings.Css = "body {\r\n background-color: red; \r\n}" +blinkConverterSettings.Css = "body { background-color: red; }" htmlConverter.ConverterSettings = blinkConverterSettings 'Convert the URL to PDF document. -Dim document As PdfDocument = htmlConverter.Convert(https://www.syncfusion.com) +Dim document As PdfDocument = htmlConverter.Convert("https://www.syncfusion.com") 'Save and close the PDF document. document.Save("Output.pdf") -document.Close(true) +document.Close(True) {% endhighlight %} @@ -2744,11 +2753,11 @@ document.Close(true) You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Inject_custom_CSS_to_HTML). -N> We're injecting custom CSS into the header tag of the input HTML/URL. +N> The custom CSS is injected into the `` tag of the input HTML or URL before rendering. ## Inject custom JavaScript -The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the 'JavaScript' property of the [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class. +The Blink rendering engine offers support for injecting custom JavaScript to be applied to an HTML string or a URL before rendering it into a PDF document using the [JavaScript](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_JavaScript) property of the [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class. {% tabs %} @@ -2802,15 +2811,15 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing 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() 'Set the Blink viewport size. -blinkConverterSettings.ViewPortSize = new Size(1280, 0) +blinkConverterSettings.ViewPortSize = New Size(1280, 0) blinkConverterSettings.Margin.All = 30 'Set the Custom JavaScript blinkConverterSettings.JavaScript = "document.querySelectorAll('img').forEach((node)=>{node.remove();})" @@ -2820,7 +2829,7 @@ Dim document As PdfDocument = htmlConverter.Convert("https://www.syncfusion.com" 'Save and close the PDF document. document.Save("Output.pdf") -document.Close(true) +document.Close(True) {% endhighlight %} @@ -2828,11 +2837,11 @@ document.Close(true) You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Inject_custom_JavaScript_to_HTML). -N> Note: We're injecting custom JavaScript into the header tag of the input HTML/URL. +N> The custom JavaScript is injected into the `` tag of the input HTML or URL before rendering. ## Performance optimization -The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the 'ReuseBrowserProcess' property of the [HtmlToPdfConverter](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html) class. +The Blink rendering engine provides support for reusing the browser process to optimize HTML to PDF performance for multiple operations using the [ReuseBrowserProcess](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html#Syncfusion_HtmlConverter_HtmlToPdfConverter_ReuseBrowserProcess) property of the [HtmlToPdfConverter](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html) class. {% tabs %} @@ -2936,9 +2945,9 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## Temporary path -The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder. +The Blink HTML converter launches a Chrome browser to perform the conversion. While launching the Chrome browser, temporary files are created in a temporary folder. -By default, HTML converter takes system temporary path (C:\Users\<>\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion. +By default, the HTML converter uses the system temporary path (`C:\Users\<>\AppData\Local\Temp` or `C:\Windows\Temp`) to perform the conversion. The temporary path can be changed by using the [TempPath](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_TempPath) property of [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html). If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example. @@ -3016,11 +3025,12 @@ document.Close(True) You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Set-temporary-path-while-converting-HTML-to-PDF). -## Blink path -When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the [BlinkPath](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_BlinkPath) property of [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html). +## Blink path -N> * The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries) -N> * The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages. +When converting HTML to a PDF document, the default reference to the Blink binaries path eliminates the need for manual addition. However, if you prefer to manually add the Blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the [BlinkPath](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_BlinkPath) property of [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html). + +N> * The BlinkBinaries will be available in the HTMLConverter installed location (`$SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries`). +N> * The BlinkBinaries are also available in the NuGet package installed location if you are using the Blink HTML converter from NuGet packages. {% tabs %} @@ -3092,9 +3102,10 @@ document.Close(True) You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Set_blink_path_in_HTML_to_PDF). ## Scale -Resizing the HTML content within a PDF can be achieved through the utilization of the [Scale](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_Scale) property of Blink in HTML Converter. -N> The scaling factor should be within the range of 0.1 to 2.0. +Resizing the HTML content within a PDF can be achieved through the use of the [Scale](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_Scale) property of the Blink HTML Converter. + +N> The scaling factor should be within the range of 0.1 to 2.0. Refer to the following code snippet to resize the page content size. @@ -3162,7 +3173,7 @@ htmlConverter.ConverterSettings = blinkConverterSettings 'Convert the URL to a PDF document. Dim document As PdfDocument = htmlConverter.Convert("https://www.syncfusion.com") 'Save a PDF document -document.Save("HTMLtoPDF.pdf") +document.Save("Output.pdf") 'Close the document. document.Close(True) @@ -3174,9 +3185,9 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## Enable Auto Scaling -The [EnableAutoScaling](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_EnableAutoScaling) property allows you to automatically scale the HTML content to fit the PDF dimensions during the conversion process. When set to true, the HTML content will be resized to fit the size of the generated PDF, ensuring that the content fits within the page without clipping or overflowing. +The [EnableAutoScaling](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_EnableAutoScaling) property allows you to automatically scale the HTML content to fit the PDF dimensions during the conversion process. When set to `true`, the HTML content will be resized to fit the size of the generated PDF, ensuring that the content fits within the page without clipping or overflowing. -N> EnableAutoScaling and GetHtmlBounds cannot be used simultaneously in the HTML to PDF conversion process. +N> EnableAutoScaling and GetHtmlBounds cannot be used simultaneously in the HTML to PDF conversion process. {% tabs %} @@ -3256,7 +3267,7 @@ document.Close(True) ## Timeout -HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter. +When HTML content takes a long time to render or convert to a PDF, you can set a conversion timeout through the use of the [ConversionTimeout](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_ConversionTimeout) property of the Blink HTML Converter. Refer to the following code snippet to set the timeout for HTML to PDF conversion. @@ -3332,9 +3343,9 @@ document.Close(True) You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Time-out-support-in-HTML-to-PDF). -## Wait For External Fonts +## Wait for External Fonts -The [WaitForExternalFonts](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_WaitForExternalFonts) property allows you to control whether the HTML to PDF conversion should wait for external fonts to load in the browser before rendering the PDF. +The [WaitForExternalFonts](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_WaitForExternalFonts) property controls whether the HTML to PDF conversion should wait for external fonts to load in the browser before rendering the PDF. {% tabs %} @@ -3412,6 +3423,8 @@ document.Close(True) {% endtabs %} +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/HTML-to-PDF-Wait-For-External-Fonts/.NET). + ## Accessible PDF The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample. @@ -3487,10 +3500,9 @@ document.Close(True) You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Accessible_PDF_In_HTML_to_PDF). - ## Image Background -The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample. +The Blink HTML converter supports adding an image background when converting HTML to an image using the [ImageBackgroundColor](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_ImageBackgroundColor) property in the [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class. Refer to the following code sample. {% tabs %} @@ -3517,7 +3529,6 @@ File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData); {% highlight c# tabtitle="C# [Windows-specific]" %} using System.Drawing; -using System.Drawing.Imaging; using Syncfusion.HtmlConverter; //Initialize HTML to PDF converter. @@ -3539,8 +3550,8 @@ for (int i = 0; i < image.Length; i++) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing Imports Syncfusion.HtmlConverter -Imports Syncfusion.Pdf ' Initialize HTML to PDF converter. Dim htmlConverter As New HtmlToPdfConverter() @@ -3553,7 +3564,7 @@ htmlConverter.ConverterSettings = settings ' Convert HTML to Image. Dim image As Image = htmlConverter.ConvertToImage("Input.html") ' Save the image. -File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData) +File.WriteAllBytes(Path.GetFullPath("Output/Output.jpg"), image.ImageData) {% endhighlight %} @@ -3563,7 +3574,7 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## Get HTML Bounds -We can calculate and retrieve the dimensions (width and height) of the HTML content based on the current settings, such as viewport width and scale, using the [GetHtmlBounds](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html#Syncfusion_HtmlConverter_HtmlToPdfConverter_GetHtmlBounds_System_String_) method in the [HtmlToPdfConverter](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html) class. +The dimensions (width and height) of the HTML content can be calculated and retrieved based on the current settings, such as viewport width and scale, using the [GetHtmlBounds](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html#Syncfusion_HtmlConverter_HtmlToPdfConverter_GetHtmlBounds_System_String_) method in the [HtmlToPdfConverter](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html) class. N> EnableAutoScaling and GetHtmlBounds cannot be used simultaneously in the HTML to PDF conversion process. @@ -3594,7 +3605,6 @@ File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData); {% highlight c# tabtitle="C# [Windows-specific]" %} using System.Drawing; -using System.Drawing.Imaging; using Syncfusion.HtmlConverter; // Initialize HTML to PDF converter @@ -3619,8 +3629,8 @@ for (int i = 0; i < image.Length; i++) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing Imports Syncfusion.HtmlConverter -Imports System.Pdf ' Initialize HTML to PDF converter Dim htmlConverter As New HtmlToPdfConverter() @@ -3635,7 +3645,7 @@ htmlConverter.ConverterSettings = blinkConverterSettings ' Convert the HTML file to an image Dim image As Image = htmlConverter.ConvertToImage(Path.GetFullPath("Input.html")) ' Save the image -File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData) +File.WriteAllBytes(Path.GetFullPath("Output/Output.jpg"), image.ImageData) {% endhighlight %} @@ -3647,7 +3657,7 @@ You can download a complete working sample from [GitHub](https://github.com/Sync The Blink HTML converter provides an option to disable local file access during the HTML-to-PDF conversion process using the [EnableLocalFileAccess](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_EnableLocalFileAccess) property in the [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class. -Refer to the following code sample to Disabling local file access. +Refer to the following code sample to disable local file access. {% tabs %} @@ -3690,25 +3700,23 @@ using Syncfusion.Pdf; // Initialize HTML to PDF converter HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); -{ - // Initialize Blink converter settings - BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); - // Set Blink viewport size - blinkConverterSettings.ViewPortSize = new Size(1280, 0); +// Initialize Blink converter settings +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +// Set Blink viewport size +blinkConverterSettings.ViewPortSize = new Size(1280, 0); - // Restricts external CSS and images in local HTML content - blinkConverterSettings.EnableLocalFileAccess = false; +// Restricts external CSS and images in local HTML content +blinkConverterSettings.EnableLocalFileAccess = false; - // Assign Blink converter settings to HTML converter - htmlConverter.ConverterSettings = blinkConverterSettings; - // Read HTML content from file - string html = File.ReadAllText("sample.html"); - // Convert HTML to PDF document - using (PdfDocument document = htmlConverter.Convert(html, "")) - { - // Save the PDF document. - document.Save("Output.pdf"); - } +// Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = blinkConverterSettings; +// Read HTML content from file +string html = File.ReadAllText("sample.html"); +// Convert HTML to PDF document +using (PdfDocument document = htmlConverter.Convert(html, "")) +{ + // Save the PDF document. + document.Save("Output.pdf"); } {% endhighlight %} @@ -3750,7 +3758,7 @@ N> This property determines whether the Blink rendering engine can load local re ## Adding Digital Signatures to HTML-converted PDFs -This section demonstrates implementing digital signatures in PDFs generated from HTML sources using [HtmlToPdfConverter](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html) class. Digital signatures provide cryptographic proof of document authenticity and integrity. +This section demonstrates implementing digital signatures in PDFs generated from HTML sources using the [HtmlToPdfConverter](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html) class. Digital signatures provide cryptographic proof of document authenticity and integrity. The following code examples demonstrate how to convert HTML to PDF and programmatically add signature fields to the generated document. @@ -3833,8 +3841,6 @@ public void AddPdfSignatureField(MemoryStream stream) using System.Drawing; using Syncfusion.HtmlConverter; using Syncfusion.Pdf; -using Syncfusion.Pdf.Interactive; -using Syncfusion.Pdf.Parsing; // Initialize the HTML to PDF converter using the Blink rendering engine HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -3971,21 +3977,25 @@ End Using {% endtabs %} -You can download a complete working sample from GitHub. +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Adding-signature-field-to-PDF-converted-from-HTML/.NET). ## Wait until browser navigation completes -The Blink rendering engine now supports waiting for specific browser navigation events before starting the HTML to PDF conversion. This ensures that the conversion begins only after the desired level of page loading is complete, improving accuracy and consistency in rendering. +The Blink rendering engine supports waiting for specific browser navigation events before starting the HTML to PDF conversion. This ensures that the conversion begins only after the desired level of page loading is complete, improving accuracy and consistency in rendering. -Supported Navigation Events +**Supported Navigation Events** You can configure the wait behavior using the [WaitForNavigation](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_WaitForNavigation) property in [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html). The following options are available via the [WaitOption](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.WaitOption.html) enum: -Load: Waits until the `load` event is fired. Ensures all external resources (images, styles, scripts) are fully loaded. -DomContentLoaded: Waits until the `DOMContentLoaded` event is fired. Does not wait for external resources. -NetworkIdle0: Waits until there are no more than 0 network connections for at least 500 ms. -NetworkIdle2: Waits until there are no more than 2 network connections for at least 500 ms. -None: No waiting; conversion starts immediately. +**Load**: Waits until the `load` event is fired. Ensures all external resources (images, styles, scripts) are fully loaded. + +**DomContentLoaded**: Waits until the `DOMContentLoaded` event is fired. Does not wait for external resources. + +**NetworkIdle0**: Waits until there are no more than 0 network connections for at least 500 ms. + +**NetworkIdle2**: Waits until there are no more than 2 network connections for at least 500 ms. + +**None**: No waiting; conversion starts immediately. N> This feature is applicable only to the Blink rendering engine and is supported in both .NET Core and .NET Framework libraries. diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/performance-metrics.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/performance-metrics.md index 5b30714ca1..b9c3a4b84a 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/performance-metrics.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/performance-metrics.md @@ -8,7 +8,7 @@ documentation: UG # HTML to PDF Performance Benchmarks -The Syncfusion® [HTML to PDF library](https://www.syncfusion.com/document-sdk/net-pdf-library/html-to-pdf) delivers high-performance APIs to convert web content into PDF documents programmatically. This performance benchmark report highlights the speed and efficiency of HTML-to-PDF conversion, showcasing how the library manages large-scale document rendering in real-world scenarios. +The [HTML to PDF library](https://www.syncfusion.com/document-sdk/net-pdf-library/html-to-pdf) delivers high-performance APIs to convert web content into PDF documents programmatically. This performance benchmark report highlights the speed and efficiency of HTML-to-PDF conversion, showcasing how the library manages large-scale document rendering in real-world scenarios. ## Environment Details diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md index 34f11c1fa5..217c131591 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md @@ -1,6 +1,6 @@ --- title: Troubleshoot HTML to PDF conversion in .NET PDF Library | Syncfusion -description: Learn how to convert HTML to PDF using the Blink rendering engine with various features like TOC, partial web page to PDF, and more. +description: Troubleshoot HTML to PDF conversion issues with the Blink rendering engine, including dependency, permission, Azure, and deployment errors. platform: document-processing control: PDF documentation: UG @@ -16,31 +16,31 @@ documentation: UG Reason -The exception may occur if the 'runtimes' folder is not copied correctly from the NuGet folder. +The exception may occur if the runtimes folder is not copied correctly from the NuGet folder. Solution -Ensure that the runtimes folder is copied properly to bin folder of the application from NuGet package location. +Ensure that the runtimes folder is copied properly to the bin folder of the application from the NuGet package location.

-Please refer to the below screenshot, +Please refer to the screenshot below:

Runtime folder

(Or)

-You can set the runtimes folder path explicitly in BlinkPath property in BlinkConverterSettings class. +You can set the runtimes folder path explicitly using the BlinkPath property in the BlinkConverterSettings class.

-Ex path: C:\HtmlConversion\HTMl-to-PDF\HTMl-to-PDF\bin\Debug\net7.0\runtimes\win-x64\native\ +Example path: C:\HtmlConversion\HTMl-to-PDF\HTMl-to-PDF\bin\Debug\net7.0\runtimes\win-x64\native\

-{% highlight C# %} +{% highlight c# %} //Initialize the HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); -//Set Blink the binaries path. +//Set the Blink binaries path. blinkConverterSettings.BlinkPath = @"C:/HtmlConversion/BlinkBinaries/"; //Assign the Blink converter settings to HTML converter. htmlConverter.ConverterSettings = blinkConverterSettings; @@ -58,49 +58,49 @@ document.Close(true); -## BlinkBinaries access is denied in server +## BlinkBinaries access is denied on the server - - -
Exception BlinkBinaries access is denied in server. +BlinkBinaries access is denied on the server.
Reason If the BlinkBinaries folder does not have elevated permission for the respective user, then the Blink HTML converter may throw this exception. +If the BlinkBinaries folder does not have elevated permission for the respective user, the Blink HTML converter may throw this exception.
Solution You can add read/write/execute permission to for the BlinkBinaries folder for the respective user group. +You can add read/write/execute permission for the BlinkBinaries folder to the respective user group.
-## Blink rendering engine only supported from .NET Framework 4.5 +## Blink rendering engine is only supported from .NET Framework 4.5 - - - @@ -118,28 +118,28 @@ document.Close(true); - - - - - - + + +{% endhighlight %} +
Exception Blink rendering engine only supported from .NET Framework 4.5. +Blink rendering engine is only supported from .NET Framework 4.5.
Reason HTML conversion using blink is only supported from .NET framework 4.5 or above. +HTML conversion using Blink is only supported from .NET Framework 4.5 or above.
Solution The application should target .NET Framework 4.5 or above to convert the HTML using the Blink rendering engine. +The application should target .NET Framework 4.5 or above to convert HTML using the Blink rendering engine.
Reason The exception may occur in the Linux CentOS/Docker environment due to the Chrome browser unable to launch from sandbox mode in CentOS. +This exception may occur in the Linux CentOS/Docker environment because the Chrome browser is unable to launch from sandbox mode in CentOS.
Solution To overcome the exception in the Linux CentOS/Docker environment, provide the execute permission for chrome and chrome-wrapper files inside the BlinkBinaries folder. +To overcome this exception in the Linux CentOS/Docker environment, provide execute permission for the chrome and chrome-wrapper files inside the BlinkBinaries folder.
-Refer to the following screenshot: +Refer to the following screenshots:
Blink chrome file permission
Blink chrome wrapper file permission
-Also, please add the following command line arguments in our converter setting. +Also, add the following command line arguments in the converter settings.
- -
-{% highlight C# tabtitle="C#" %} +{% highlight c# %} //Set command line arguments to run without sandbox. blinkConverterSettings.CommandLineArguments.Add("--no-sandbox"); @@ -167,14 +167,14 @@ blinkConverterSettings.CommandLineArguments.Add("--disable-setuid-sandbox");
Reason The exception may occur due to missing of required dependent packages. +This exception may occur due to missing required dependent packages.
Solution To overcome the exception, you can ensure the required dependency in docker file. +To overcome this exception, ensure the required dependencies are installed in the Docker file.
@@ -189,15 +189,13 @@ blinkConverterSettings.CommandLineArguments.Add("--disable-setuid-sandbox");
Reason The required dependencies for the Chromium are not installed on the system. +The required dependencies for Chromium are not installed on the system.
Solution -Ensure all required dependencies for the Chromium are installed on the system. This may include additional libraries or packages. -Ensure all required dependencies for the Chromium are installed on the system. This may include additional libraries or packages. -Here's how you can modify your Docker file: +
Solution +Ensure all required dependencies for Chromium are installed on the system. This may include additional libraries or packages. Here's how you can modify your Docker file: {% highlight dockerfile %} FROM your-base-image RUN apt-get update && apt-get install -yq --no-install-recommends \ @@ -227,8 +225,8 @@ RUN apt-get update && apt-get install -yq --no-install-recommends \ libgbm1 \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -{% endhighlight %} -
@@ -243,7 +241,7 @@ RUN apt-get update && apt-get install -yq --no-install-recommends \ Reason -Starting with Syncfusion package version 29.X.X, Chromium was updated to 133.x.x, which now requires the `locales` directory to be present at runtime. However, when publishing a .NET application with the `linux-x64` runtime identifier, only files are copied to the root output folder and the folder structure including 'locales' is omitted. As a result, Chromium cannot locate the required 'locales' directory, triggering a runtime exception during HTML rendering or conversion. +Starting with Syncfusion package version 29.X.X, Chromium was updated to 133.x.x, which now requires the `locales` directory to be present at runtime. However, when publishing a .NET application with the `linux-x64` runtime identifier, only files are copied to the root output folder and the folder structure including `locales` is omitted. As a result, Chromium cannot locate the required `locales` directory, triggering a runtime exception during HTML rendering or conversion. @@ -251,16 +249,16 @@ RUN apt-get update && apt-get install -yq --no-install-recommends \ Solution -To overcome this issue, we have three workaround solutions. +There are three workaround solutions to overcome this issue.
-Step 1: Using the "Portable" Runtime Identifier ensures that the runtime files are copied into the correct folder structure, allowing the conversion process to complete without any issues.
-Step 2: To resolve this issue, we recommend copying the runtimes folder into the project directory, placing it at the same level as the .csproj file. Additionally, ensure that all files within the runtimes folder have their Copy to Output Directory property set to Copy if newer. Please refer to the screenshot below for guidance.
+Step 1: Using the Portable Runtime Identifier ensures that the runtime files are copied into the correct folder structure, allowing the conversion process to complete without any issues.
+Step 2: Copy the runtimes folder into the project directory, placing it at the same level as the .csproj file. Additionally, ensure that all files within the runtimes folder have their Copy to Output Directory property set to Copy if newer. Please refer to the screenshot below for guidance.
Output dictionary path
-Step 3: If manually copying the files doesn't meet your requirements, we recommend applying the following code changes in the .csproj file and updating the publish profile. This will ensure the necessary files are copied automatically during the publishing process.
+Step 3: If manually copying the files does not meet your requirements, apply the following code changes in the .csproj file and update the publish profile. This ensures the necessary files are copied automatically during the publishing process.
Add the following code snippet to the .pubxml file to apply the necessary configuration.
-{% highlight C# tabtitle="C#" %} +{% highlight xml %} false @@ -268,9 +266,9 @@ Add the following code snippet to the .pubxml file to apply the necessary {% endhighlight %} -Add the following code to the .csproj file to ensure the locale folder is copied to the publish directory during the build process.
+Add the following code to the .csproj file to ensure the locales folder is copied to the publish directory during the build process.
-{% highlight C# tabtitle="C#" %} +{% highlight xml %} .csproj file to ensure the locale fo Reason -The exception may occur if the runtimes folder is not accessed. +The exception may occur if the runtimes folder cannot be accessed. Solution -To overcome the exception, you can add read, write, and execute permissions for the runtimes folder. +To overcome this exception, add read, write, and execute permissions for the runtimes folder. @@ -328,10 +326,10 @@ Add the following code to the .csproj file to ensure the locale fo Solution -To overcome the exception, you can add read, write, and execute permissions for the temporary folder. Refer to the following code sample to set the temp folder. +To overcome this exception, add read, write, and execute permissions for the temporary folder. Refer to the following code sample to set the temp folder.

-{% highlight C# tabtitle="C#" %} +{% highlight c# %} BlinkConverterSettings settings = new BlinkConverterSettings(); settings.TempPath = "D://MyProject//bin"; @@ -354,14 +352,14 @@ settings.TempPath = "D://MyProject//bin"; Reason -If the temporary folder does not have elevated permission for the respective user, then the Blink HTML converter may throw this exception. +If the temporary folder does not have elevated permission for the respective user, the Blink HTML converter may throw this exception. Solution -The Blink HTML converter has support for setting the temporary path. Using the TempPath property, you can set any folder path that has read/write/execute permission. Then, the converter uses this path for creating temporary files. +The Blink HTML converter supports setting the temporary path. Using the TempPath property, you can set any folder path that has read/write/execute permission. Then, the converter uses this path for creating temporary files. @@ -379,16 +377,16 @@ settings.TempPath = "D://MyProject//bin"; Reason -When the webpage (HTML) is not available or accessible. +The webpage (HTML) is not available or accessible. Solution -Please check the internet connection and the HTML page is available in the mentioned location. +Check the internet connection and ensure the HTML page is available at the specified location.

-Check the HTML file or URL is rendered properly in Chrome browser's print preview. +Also, verify that the HTML file or URL is rendered properly in the Chrome browser's print preview. @@ -411,12 +409,12 @@ Check the HTML file or URL is rendered properly in Chrome browser's print previe Solution -To overcome this exception, you can provide an execute permission for chrome and chrome-wrapper files inside the runtimes/linux/native folder by using the docker command. +To overcome this exception, provide execute permission for the chrome and chrome-wrapper files inside the runtimes/linux/native folder using the Docker command.

ExcludeAssets

-{% highlight C# tabtitle="C#" %} +{% highlight dockerfile %} RUN chmod +x /app/runtimes/linux/native/chrome && \ chmod +x /app/runtimes/linux/native/chrome-wrapper @@ -438,16 +436,16 @@ RUN chmod +x /app/runtimes/linux/native/chrome && \ Reason -The issue may be due to the slow internet connection or due to the behavior that the conversion completed before the page is loaded completely. +The issue may be due to a slow internet connection, or because the conversion completed before the page was loaded completely. Solution -To overcome this issue, add suitable delay for the conversion using the AdditionalDelay property of the HTMLConverter. +To overcome this issue, add a suitable delay for the conversion using the AdditionalDelay property of the HTMLConverter.

-{% highlight C# tabtitle="C#" %} +{% highlight c# %} BlinkConverterSettings settings = new BlinkConverterSettings(); settings.AdditionalDelay = 4000; @@ -460,13 +458,13 @@ settings.AdditionalDelay = 4000; Reason -While converting HTML string to PDF, the resources may be missed due to the invalid Base URL. +While converting an HTML string to PDF, the resources may be missed due to an invalid base URL. Solution -Overcome this issue by passing the valid base URL (path of the resources) along with the HTML string. +Overcome this issue by passing a valid base URL (path of the resources) along with the HTML string. @@ -478,21 +476,21 @@ settings.AdditionalDelay = 4000; Issue Blink conversion failed in Azure app service (Windows). -“The process was terminated due to an unhandled exception” +"The process was terminated due to an unhandled exception" Reason -Blink rendering engine uses GDI calls for viewing and rendering the webpages. But Azure app service blocks GDI calls in Azure website environment. As azure website does not have the elevated permission and enough rights, so we could not launch the Chrome headless browser in Azure app service (Azure website and Azure function). +The Blink rendering engine uses GDI calls for viewing and rendering webpages. However, Azure app service blocks GDI calls in the Azure website environment. Since the Azure website does not have elevated permissions or sufficient rights, the Chrome headless browser cannot be launched in Azure app service (Azure website and Azure function). Solution -You can convert HTML to PDF using the Blink rendering engine in Azure cloud service (which has the elevated permission and rights to access the GDI calls). -Refer to this link for more information. +You can convert HTML to PDF using the Blink rendering engine in Azure cloud service, which has elevated permissions and rights to access GDI calls. +Refer to this link for more information. @@ -543,17 +541,17 @@ These plans provide the necessary environment and permissions to support Chromiu Reason -The issue is happen due to invalid SSL certificate errors in unsecured sites. +This issue occurs due to invalid SSL certificate errors on unsecured sites. Solution -You can able to bypass the invalid SSL certificate errors using the command line arguments property of Blink converter settings. +You can bypass the invalid SSL certificate errors using the CommandLineArguments property of Blink converter settings.

-{% highlight C# tabtitle="C#" %} +{% highlight c# %} BlinkConverterSettings settings = new BlinkConverterSettings(); settings.CommandLineArguments.Add("--ignore-certificate-errors"); @@ -577,20 +575,20 @@ settings.CommandLineArguments.Add("--ignore-certificate-errors"); The HTML-to-PDF conversion relies on Chromium's Blink rendering engine:
-1.The NuGet package includes Blink binaries (`chrome.exe`) under `runtimes/win-x64/native`
-3.Security systems flag the execution of embedded binaries as potential risks
+1. The NuGet package includes Blink binaries (`chrome.exe`) under `runtimes/win-x64/native`.
+2. This bundled Chrome instance launches in headless mode to render web content.
+3. Security systems flag the execution of embedded binaries as potential risks.
Solution -Use system-installed Chromium instead of bundled binaries: +Use system-installed Chromium instead of the bundled binaries:

-Step 1: Configure Blink Path +Step 1: Configure the Blink Path -{% highlight C# tabtitle="C#" %} +{% highlight c# %} HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); BlinkConverterSettings settings = new BlinkConverterSettings(); @@ -608,35 +606,35 @@ document.Close(true); {% endhighlight %} -Step 2: Verify Installation
+Step 2: Verify Installation
Ensure Chrome exists at the specified path (standard locations): `C:\Program Files\Google\Chrome\Application` -## Conversion failure in windows server 2012 R2 +## Conversion failure in Windows Server 2012 R2 - - -
Issue Conversion failure in windows server 2012 R2. +Conversion failure in Windows Server 2012 R2.
Reason The issue may happen due to windows server environment permission restriction. +The issue may occur due to Windows Server environment permission restrictions.
Solution We can resolve this permission related failure in the Blink rendering engine using below command line arguments in our converter settings. +This permission-related failure in the Blink rendering engine can be resolved using the following command line arguments in the converter settings.

-{% highlight C# tabtitle="C#" %} +{% highlight c# %} //Set command line arguments to run without sandbox. blinkConverterSettings.CommandLineArguments.Add("--no-sandbox"); @@ -648,35 +646,35 @@ blinkConverterSettings.CommandLineArguments.Add("--disable-setuid-sandbox");
-## Converting the HTML to PDF fails in x32 bit windows system environment +## Converting HTML to PDF fails in x32 bit Windows system environment - - -
Exception Converting the HTML to PDF fails in x32 bit windows system environment. +Converting HTML to PDF fails in x32 bit Windows system environment.
Reason The existing x64 bit Blink binaries windows are not compatible with x32 bit windows system architecture. +The existing x64 bit Blink binaries for Windows are not compatible with the x32 bit Windows system architecture.
Solution To overcome this issue, we can use the x32 bit blink binaries. The x32 bit windows blink binaries are compatible with the x32 bit windows system environment. Please download the x32 bit blink binaries for windows here and replace these binaries in the existing x64 bit blink binaries folder. +To overcome this issue, use the x32 bit Blink binaries. The x32 bit Windows Blink binaries are compatible with the x32 bit Windows system environment. Please download the x32 bit Blink binaries for Windows here and replace these binaries in the existing x64 bit Blink binaries folder.
-## Hyperlinks appearances do not navigate to their referenced URLs when using `CreateTemplate` and `DrawPdfTemplate` methods +## Hyperlink appearances do not navigate to their referenced URLs when using `CreateTemplate` and `DrawPdfTemplate` methods - @@ -690,60 +688,48 @@ blinkConverterSettings.CommandLineArguments.Add("--disable-setuid-sandbox");
Issue Hyperlinks appearances do not navigate to their referenced URLs when using `CreateTemplate` and `DrawPdfTemplate` methods +Hyperlink appearances do not navigate to their referenced URLs when using `CreateTemplate` and `DrawPdfTemplate` methods
Solution A workaround involves manually extracting and re-applying hyperlink annotations. This can be achieved by following these steps:
-1.Extract Annotations: Before creating and drawing the PDF template, extract all annotations, specifically hyperlink annotations, from the original PDF document.
-2.Draw PDF Template: Use the CreateTemplate and DrawPdfTemplate methods to draw the PDF content into a new document.
-3.Incorporate Annotations: After the template has been drawn, programmatically add the extracted hyperlink annotations to the corresponding positions in the new document. This will restore the interactive functionality of the hyperlinks.
+1. Extract Annotations: Before creating and drawing the PDF template, extract all annotations, specifically hyperlink annotations, from the original PDF document.
+2. Draw PDF Template: Use the CreateTemplate and DrawPdfTemplate methods to draw the PDF content into a new document.
+3. Incorporate Annotations: After the template has been drawn, programmatically add the extracted hyperlink annotations to the corresponding positions in the new document. This will restore the interactive functionality of the hyperlinks.
Please refer to the sample project: HTML-to-PDF-Hyperlink
-## ERROR:The specified module could not be found in windows server 2012 R2 +## ERROR: The specified module could not be found in Windows Server 2012 R2 - - -
Exception The specified module could not be found in windows server 2012 R2. +The specified module could not be found in Windows Server 2012 R2.
Reason The issue happened because the Windows Server Essentials Media Pack was missing in the Windows server 2012 R2. +This issue occurs because the Windows Server Essentials Media Pack is missing on Windows Server 2012 R2.
Solution We can resolve this issue by installing the Windows Server Essentials Media Pack. +This issue can be resolved by installing the Windows Server Essentials Media Pack. To install the Windows Server Essentials Media Pack, first install the Windows Server Essentials.
-1. Open the Server Manager in the Taskbar.
-2. Click Manage in the Server Manager and select Add Roles and Features option.
-3. Select the Role-based or feature-based installation option and click next.
-4. In the left side menu, select server roles, then Windows Server Essentials Experience in the server roles and then click next.
-5. Now, the Windows Server Essentials will be installed.
-6. After successful installation, install the Windows Server Essentials Media Pack.
-Go to the official website to download and Install the Windows Server Essentials Media Pack.

+1.Open the Server Manager in the Taskbar.
+2.Click Manage in the Server Manager and select Add Roles and Features.
+3.Select the Role-based or feature-based installation option and click Next.
+4.In the left side menu, select Server Roles, then enable Windows Server Essentials Experience, and click Next.
+5.The Windows Server Essentials will be installed.
+6.After successful installation, install the Windows Server Essentials Media Pack.
+Go to the official website to download and install the Windows Server Essentials Media Pack.

-{{'**Note:**'| markdownify }}This version is only applicable to Windows Server 2012 R2 Standard. +**Note:** This version is only applicable to Windows Server 2012 R2 Standard.
-## How to Exclude BlinkBinaries or Runtime Files in Build or Deployment - -The runtime files, or blink binaries, will be copied into a bin or published folder while building and publishing the application. - -By including the native option in the package reference of the csproj file, you can exclude the runtime files or blink binaries from being copied into the bin or publish folder while building and publishing the application. But you need to place the BlinkBinaries in the server disk and set the BlinkPath in the BlinkConverterSettings to perform the conversion. - -{{'**Note:**'| markdownify }}Using this approach, you can reduce the deployment size on your own servers. - -Refer to the following package reference: - -ExcludeAssets
- ## HTML conversion support in Azure @@ -768,7 +754,7 @@ Refer to the following package reference:
-## Failed to convert Webpage exception with Linux docker in Mac M1 machine. +## Failed to convert Webpage exception with Linux Docker on Mac M1 machine - @@ -787,11 +773,11 @@ Refer to the following package reference: - @@ -841,10 +827,14 @@ settings.BlinkPath = @"/usr/lib/chromium/chromium";
Exception @@ -779,7 +765,7 @@ Refer to the following package reference:
Reason The existing x64-bit Blink binaries for Linux are not compatible with the x64 ARM Mac M1 system architecture with Linux Docker. +The existing x64-bit Blink binaries for Linux are not compatible with the ARM64 Mac M1 system architecture running Linux Docker.
Solution -To resolve this issue, we can install the chromium using the docker file and set the Blink Path to the location where chromium is installed. +To resolve this issue, install Chromium using the Dockerfile and set the Blink Path to the location where Chromium is installed.

-Docker File:

+Dockerfile:

-{% highlight C# tabtitle="C#" %} +{% highlight dockerfile %} FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base RUN apt-get update && apt-get install -y \ @@ -806,9 +792,9 @@ EXPOSE 443 {% endhighlight %} -Code example: +Code example: -{% highlight C# tabtitle="C#" %} +{% highlight c# %} BlinkConverterSettings settings = new BlinkConverterSettings(); @@ -833,7 +819,7 @@ settings.BlinkPath = @"/usr/lib/chromium/chromium";
Reason We do not have the support for adding a custom CSS style in the HTML header and footer. +Adding a custom CSS style in the HTML header and footer is not supported.
Solution -To resolve this issue, we can add inline styles in element. However, we have attached the sample and output documents for your reference. +To resolve this issue, add inline styles to the element. The following sample demonstrates the approach.

-{% highlight C# tabtitle="C#" %} +{% highlight c# %} + +using Syncfusion.Drawing; +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); //Initialize blink converter settings. @@ -862,7 +852,7 @@ blinkConverterSettings.HtmlFooter = "
Hello World
",string.Empty); +PdfDocument document = htmlConverter.Convert("
Hello World
", string.Empty); //Save and close a PDF document. document.Save("Output.pdf"); @@ -870,17 +860,17 @@ document.Close(true); {% endhighlight %} -You can downloaded a complete working sample from GitHub. +You can download a complete working sample from GitHub.
-## Zombie process are not closed by default from chrome headless in Linux platform +## Zombie processes are not closed by default from chrome headless on Linux platform - The zombie process are not closed by default from chrome headless in Linux. However, We can resolve the zombie process issue by using the below command line arguments in converter settings. +Zombie processes are not closed by default from chrome headless in Linux. However, this issue can be resolved by using the following command line arguments in the converter settings. -{% highlight C# %} +{% highlight c# %} //Set command line arguments to run without the sandbox. settings.CommandLineArguments.Add("--no-sandbox"); @@ -900,35 +890,35 @@ settings.CommandLineArguments.Add("--single-process"); Reason -The reported issue occurs due to missing of required Linux dependencies in Azure function to perform the conversion in premium plans (such as Ep1) +This issue occurs due to missing required Linux dependencies in the Azure function to perform the conversion in premium plans (such as EP1). Solution -To overcome this issue by installing the Linux dependencies package in SSH window. Please refer the below commands and screenshot, +To overcome this issue, install the Linux dependencies package using the SSH window. Please refer to the commands and screenshot below: -{% highlight C# %} +{% highlight bash %} apt-get update && apt-get install -yq --no-install-recommends libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 libnss3 libgbm1 {% endhighlight %}

-Please refer to the below screenshot, +Please refer to the screenshot below:

Failed to launch chromium logo


(Or)

-We can install the required dependencies using the dependencies vis shell script. Please find the below. +The required dependencies can also be installed using a shell script.

HTML Conversion Dependencies Logo


-Code example: +Code example:

-{% highlight C# %} +{% highlight c# %} private static void InstallLinuxPackages(FileInfo functionAppDirectory) { @@ -973,10 +963,8 @@ private static void InstallLinuxPackages(FileInfo functionAppDirectory) - - ## Failed to load Chrome DLL exception occurs on Windows 7/8 and Windows Server 2008/2012 machines @@ -986,7 +974,7 @@ private static void InstallLinuxPackages(FileInfo functionAppDirectory) - @@ -995,17 +983,13 @@ private static void InstallLinuxPackages(FileInfo functionAppDirectory) If you are using Windows 7/8 or Windows Server 2008/2012, please use Chromium version 109 instead of the newer versions. Chromium has discontinued support for these operating systems, and the last compatible version is 109.

-Please refer to the below thread for more information, +Please refer to the thread below for more information: Thread -
- -Blink binaries (Version 109.0.5414.75), +Blink binaries (Version 109.0.5414.75): Blink Binaries - -
Reason The reported issue occurs due to an unsupported OS platform with the latest binaries. +This issue occurs due to an unsupported OS platform with the latest binaries.
## There was an error opening this document. This file is already open or in use by another application. @@ -1017,16 +1001,16 @@ Blink binaries (Version 109.0.5414.75), Reason -The reported issue occurs due to the document or file not being properly disposed or closed, leading to conflicts when attempting to access it again. +This issue occurs because the document or file is not properly disposed or closed, leading to conflicts when attempting to access it again. Solution -We can resolve the reported issue by using the FileStream within the "using" block. +This issue can be resolved by using the `FileStream` within a `using` block. -{% highlight C# %} +{% highlight c# %} using (FileStream fs = new FileStream("path_to_file", FileMode.Open)) { @@ -1035,12 +1019,11 @@ using (FileStream fs = new FileStream("path_to_file", FileMode.Open)) {% endhighlight %} - Or -Dispose of the FileStream at the end of the process and ensure that the file or document is not already open in another application. +Dispose of the `FileStream` at the end of the process and ensure that the file or document is not already open in another application. -{% highlight C# %} +{% highlight c# %} PdfDocument document = htmlConverter.Convert("); FileStream fileStream = new FileStream(baseUrl+ "Bill_PDF_04_16_24.pdf", FileMode.CreateNew, FileAccess.ReadWrite); @@ -1055,7 +1038,6 @@ fileStream.Dispose(); - ## Custom fonts are not rendered in Azure App Service and Function Linux using Blink. @@ -1067,9 +1049,9 @@ fileStream.Dispose(); Reason -We are internally using the Blink rendering engine to convert HTML to PDF document. Due to the sandbox GDI limitation on Azure App services and Function, custom fonts are not rendered (system-installed font is used instead) because of sandbox GDI API limitations that present even in VM-based Azure Apps plans. So, that the converter will automatically renders with default font. +Internally, the Blink rendering engine is used to convert HTML to PDF. Due to the sandbox GDI limitation on Azure App Services and Functions, custom fonts are not rendered (the system-installed font is used instead) because of sandbox GDI API limitations that exist even in VM-based Azure Apps plans. As a result, the converter automatically renders with the default font. -Refer below link for more information. This is a limitation of Azure cloud environment. +Refer to the link below for more information. This is a limitation of the Azure cloud environment. Azure Web App sandbox @@ -1077,7 +1059,7 @@ Refer below link for more information. This is a limitation of Azure cloud envir Solution -we can overcome this issue by using Azure cloud service which has the elevated access permissions. If it is possible to use Azure cloud service API for converting HTML to PDF. Please refer below link for converting HTML to PDF in Azure cloud service. The custom font may work in Azure cloud service/Azure VM, we ensured this by creating simple sample in Azure VM and the font is working properly. If possible, kindly use the Azure cloud service with VM to resolve the reported issue. +This issue can be overcome by using Azure cloud service, which has elevated access permissions. Use the Azure cloud service API for converting HTML to PDF. Please refer to the link below for converting HTML to PDF in Azure cloud service. The custom font may work in Azure cloud service/Azure VM; this was verified by creating a simple sample in an Azure VM, where the font renders properly. If possible, use the Azure cloud service with a VM to resolve this issue. KB: Convert HTML to PDF in Azure using Blink @@ -1085,26 +1067,26 @@ KB: Issue -Blink files are missing at /user/local/bin while performing HTML to PDF conversion with docker and docker compose file. +Blink files are missing at /user/local/bin while performing HTML to PDF conversion with Docker and docker-compose file. Reason - -The exception may occur while performing HTML to PDF conversion with docker and docker compose file due to a permission-related issues. + +This exception may occur while performing HTML to PDF conversion with Docker and docker-compose file due to permission-related issues. Solution -To overcome the exception by making the root files as executable. For making the root files as executable, you can find the code snippet below which will be added to your docker file. +To overcome this exception, mark the root files as executable. The following code snippet can be added to your Dockerfile: -{% highlight C# %} +{% highlight dockerfile %} USER root RUN chmod +x /app/runtimes/linux/native/chrome && \ @@ -1113,7 +1095,7 @@ chmod +x /app/runtimes/linux/native/chrome-wrapper {% endhighlight %}

-Please refer to the below screenshot, +Please refer to the screenshot below:

Runtime folder

@@ -1123,17 +1105,17 @@ Please refer to the below screenshot, -## Converting HTML to PDF using the Alpine Docker image, it crashes after the first conversion. +## Converting HTML to PDF using the Alpine Docker image crashes after the first conversion. - - @@ -1141,9 +1123,9 @@ The issue occurs within Chromium specifically for Alpine. - @@ -1264,7 +1246,7 @@ Please refer the Chrom - @@ -1273,14 +1255,14 @@ The Blink rendering engine is not supported for HTML to PDF conversion in Azu @@ -1296,11 +1278,11 @@ To perform HTML to PDF conversion using the Blink rendering engine, you can use - @@ -1309,39 +1291,39 @@ This issue may occur due to one of the following reasons:
@@ -1357,28 +1339,28 @@ For more details to install the dependencies through SSH terminal window, refer - - - @@ -1459,10 +1441,10 @@ After applying this change, all required dependencies are installed successfully
IssueConverting HTML to PDF using the Alpine Docker image, it crashes after the first conversion. +Converting HTML to PDF using the Alpine Docker image crashes after the first conversion.
Reason - + + The issue occurs within Chromium specifically for Alpine.
Solution -We can resolve this issue by adding command-line arguments to the Blink converter settings. Please refer to the code snippet below. +This issue can be resolved by adding command-line arguments to the Blink converter settings. Please refer to the code snippet below: -{% highlight C# %} +{% highlight c# %} blinkConverterSettings.CommandLineArguments.Add("--disable-gpu"); @@ -1163,20 +1145,20 @@ blinkConverterSettings.CommandLineArguments.Add("--disable-gpu");
Reason - -The reported issue may occur due to missing of crashpad handler configuration in your docker file + + +This issue may occur due to missing crashpad handler configuration in the Dockerfile.
Solution -You can try the below solution steps to overcome the reported issue 'Failed to launch Base! chrome_crashpad_handler: --database is required',
+You can try the following solution steps to overcome the issue `'Failed to launch Base! chrome_crashpad_handler: --database is required'`:
-Step 1: Kindly try the below docker file changes in your sample to resolve the chrome_crashpad_handler issue.
+Step 1: Apply the following Dockerfile changes in your sample to resolve the `chrome_crashpad_handler` issue.
-{% highlight C# %} +{% highlight dockerfile %} FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine LABEL pipelineName="PDFSearch" \ @@ -1218,22 +1200,22 @@ ENTRYPOINT ["dotnet", "Ops.PDFSearch.Web.dll"] {% endhighlight %} -We have attached the modified docker file for your reference Docker file.
+A modified Dockerfile is available for your reference: Docker file.
-Step 2: From chromium version 128.x.x.x.x -database flag required for chrome Crashpad handler. So, it may cause the issue on your end. So kindly try the below steps and it may resolve the reported issue.
+Step 2: From Chromium version 128.x.x.x.x, the `--database` flag is required for the Chrome crashpad handler. This may cause the issue on your end. Try the steps below to resolve the issue.
-Add below commands in Docker file:
+Add the following commands in the Dockerfile:
-{% highlight C# %} +{% highlight dockerfile %} RUN mkdir -p /var/www/.config/google-chrome/Crashpad RUN chown -R www-data:www-data /var/www/.config {% endhighlight %} -Add below command-line arguments in conversion code
+Add the following command-line arguments in the conversion code:
-{% highlight C# %} +{% highlight c# %} if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { @@ -1248,7 +1230,7 @@ if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {% endhighlight %} -Please refer the Chromium forum link. for more information about the reported issue +Please refer to the Chromium forum link for more information about this issue.
Reason + The Blink rendering engine is not supported for HTML to PDF conversion in Azure App Service (Windows) due to the GDI limitations and restrictions inherent in the Azure App Service environment. Solution -Use Blink Rendering Engine in Azure App Service Linux or Azure Functions Linux
+Use the Blink Rendering Engine in Azure App Service Linux or Azure Functions Linux
To perform HTML to PDF conversion using the Blink rendering engine, you can use the following alternatives:
-* Azure App Service (Linux): The Blink rendering engine is compatible with Azure App Service running on Linux.
+*Azure App Service (Linux): The Blink rendering engine is compatible with Azure App Service running on Linux.
-* Azure Functions (Linux): Linux-based Azure Functions can also utilize the Blink rendering engine for successful conversions.
-* Azure App Service (Linux Docker): Deploying the application in a Linux-based Docker container offers another way to use Blink.
+*Azure Functions (Linux): Linux-based Azure Functions can also utilize the Blink rendering engine for successful conversions.
+*Azure App Service (Linux Docker): Deploying the application in a Linux-based Docker container offers another way to use Blink.
Reason + This issue may occur due to one of the following reasons:
-1. Missing required Linux dependencies
-2. Missing Chromium dependency files
-3. Lack of access permissions for the chrome and chrome-wrapper files
+1.Missing required Linux dependencies
+2.Missing Chromium dependency files
+3.Lack of access permissions for the `chrome` and `chrome-wrapper` files
To resolve the issue and ensure successful HTML to PDF conversion in Azure App Service (Linux), follow these steps:
-1: Grant File Access Permissions
+1: Grant File Access Permissions
-Provide read, write, and execute permissions for the chrome and chrome-wrapper files located in the runtimes/linux/native directory. Use the following commands: +Provide read, write, and execute permissions for the `chrome` and `chrome-wrapper` files located in the `runtimes/linux/native` directory. Use the following commands: -{% highlight C# %} +{% highlight bash %} chmod +rwx chrome-wrapper chmod +rwx chrome {% endhighlight %} -2: Verify Chrome Dependency Packages
+2: Verify Chrome Dependency Packages
-Check if the necessary dependencies for Chromium are installed by running the following command in the runtimes/linux/native directory: +Check if the necessary dependencies for Chromium are installed by running the following command in the `runtimes/linux/native` directory: -{% highlight C# %} +{% highlight bash %} ldd chrome {% endhighlight %} -3: Install Required Dependencies
+3: Install Required Dependencies
-We can also perform HTML to PDF conversion in Azure App Service (Linux) by installing the required dependencies directly through SSH terminal. Use the following command: +You can also perform HTML to PDF conversion in Azure App Service (Linux) by installing the required dependencies directly through the SSH terminal. Use the following command: -{% highlight C# %} +{% highlight bash %} apt-get update && apt-get install -yq --no-install-recommends libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 libnss3 libgbm1 {% endhighlight %} -For more details to install the dependencies through SSH terminal window, refer to the documentation: -Convert HTML to PDF in Azure App Service on Linux| Syncfusion +For more details on installing the dependencies through the SSH terminal window, refer to the documentation: +Convert HTML to PDF in Azure App Service on Linux | Syncfusion
Reason -User Interaction: The App service might start before installing the required prerequisites causing user interaction. + +User Interaction: The App service might start before installing the required prerequisites, causing user interaction.
Solution -1.Script Execution at Startup
-Copy the prerequisites script (dependenciesInstall.sh) into your application directory.
+1.Script Execution at Startup
+Copy the prerequisites script (`dependenciesInstall.sh`) into your application directory.
Ensure it is configured to always be copied to the output directory during build/publish.
Runtime folder
-2.Deploy to Azure App Service (Linux)
+2.Deploy to Azure App Service (Linux)
Publish your application to the Azure App Service.
-3.Configure Startup Command
+3.Configure Startup Command
After deployment, go to the Azure portal configuration for your app service.
In the Startup Command section, add:
-{% highlight C# %} +{% highlight bash %} /home/site/wwwroot/dependenciesInstall.sh && dotnet YourApplicationName.dll @@ -1387,13 +1369,13 @@ In the Startup Command section, add:

Runtime folder
-This ensures that your script runs to install necessary dependencies before the application launches. +This ensures that your script runs to install the necessary dependencies before the application launches.
-4.Restart the App Service +4.Restart the App Service
This will trigger the execution of your startup script, resolving installation and font issues.
-5.Verification +5.Verification
After the service restarts, try the conversion or operation again to ensure the issues are resolved.
@@ -1411,18 +1393,18 @@ After the service restarts, try the conversion or operation again to ensure the
Reason -Time64 transition: Ubuntu 24.04 adopted 64-bit timestamp support, renaming several libraries with the t64 suffix. libasound2 is now a virtual package provided by libasound2t64, so installing libasound2 directly fails. + +Time64 transition: Ubuntu 24.04 adopted 64-bit timestamp support, renaming several libraries with the t64 suffix. `libasound2` is now a virtual package provided by `libasound2t64`, so installing `libasound2` directly fails. -Deprecated removal: libgconf-2-4 was deprecated and removed starting with Ubuntu 23.10 and is not available in 24.04 repositories. +Deprecated removal: `libgconf-2-4` was deprecated and removed starting with Ubuntu 23.10 and is not available in 24.04 repositories.
Solution -Update the dependency installation script to use t64 packages and omit libgconf-2-4. The following command installs the supported libraries on Ubuntu 24.04: +Update the dependency installation script to use t64 packages and omit `libgconf-2-4`. The following command installs the supported libraries on Ubuntu 24.04: -{% highlight C# %} +{% highlight bash %} Run apt-get update && apt-get install -yq --no-install-recommends \ libasound2t64 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 \ @@ -1451,7 +1433,7 @@ After applying this change, all required dependencies are installed successfully
Reason The HTML to PDF converter launches the Blink rendering engine (Chromium headless browser) internally and converts the content at the specified URL or HTML string. If culture or language selection (such as switching from English to German) is implemented using cookies (e.g.,.AspNetCore.Culture), the URL itself does not change; only cookies control the localization. The converter does not automatically read or apply browser cookies set during user interaction, so the correct culture is not applied during rendering resulting in the default (often English) content in the PDF. +The HTML to PDF converter launches the Blink rendering engine (Chromium headless browser) internally and converts the content at the specified URL or HTML string. If culture or language selection (such as switching from English to German) is implemented using cookies (e.g., .AspNetCore.Culture), the URL itself does not change; only cookies control the localization. The converter does not automatically read or apply browser cookies set during user interaction, so the correct culture is not applied during rendering, resulting in the default (often English) content in the PDF.
Solution To ensure that the correct localized or culture-specific content appears in the generated PDF:
-Set the required culture cookie explicitly using the Cookies property in BlinkConverterSettings before starting conversion.
+Set the required culture cookie explicitly using the Cookies property in BlinkConverterSettings before starting the conversion.
Example for setting German culture:
-{% highlight C# %} +{% highlight c# %} HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); BlinkConverterSettings settings = new BlinkConverterSettings(); @@ -1480,9 +1462,9 @@ PdfDocument doc = htmlConverter.Convert(url); ## Due to insufficient permissions, we are unable to launch the Chromium process for conversion in Azure Function .NET 8.0 with premium plans. -The problem is limited to Azure Functions with premium plans in Net 8.0 version. To fix this, we can either manually install the necessary Chromium dependencies in the SSH portal or include the runtimes folder (Blink binaries) in the project location. +The problem is limited to Azure Functions with premium plans in .NET 8.0 version. To fix this, manually install the necessary Chromium dependencies in the SSH portal or include the runtimes folder (Blink binaries) in the project location. -Prerequisites dependencies: +**Prerequisites dependencies:** {% highlight bash %} @@ -1490,10 +1472,10 @@ apt-get update && apt-get install -yq --no-install-recommends libasound2 libatk1 {% endhighlight %} -N> We have option to exclude the default Blink binaries from the installation package. This will reduce the size of your deployment package in azure. Please refer to the code example below. +N> You have the option to exclude the default Blink binaries from the installation package. This reduces the size of your deployment package in Azure. Please refer to the code example below. {% tabs %} -{% highlight XAML %} +{% highlight xml %} native @@ -1506,15 +1488,16 @@ N> We have option to exclude the default Blink binaries from the installation pa When you build or publish the application, the Syncfusion HTML‑to‑PDF converter automatically copies the Blink runtime files (BlinkBinaries) into the bin or publish output folder. These binaries are required for HTML‑to‑PDF conversion at runtime. However, in certain deployment scenarios—such as reducing the deployment size or using a shared/system‑installed Chromium—you can exclude these files and instead provide the Blink binaries manually on the host machine. -To exclude BlinkBinaries during the build process, configure your project file depending on whether you are using .NET Core/.NET or .NET Framework. +To exclude BlinkBinaries during the build process, configure your project file depending on whether you are using **.NET Core/.NET** or **.NET Framework**. + +**Exclude BlinkBinaries in .NET Core** -Exclude BlinkBinaries in .NET Core -You can prevent runtime files from being included by restricting the package to compile-only assets using the IncludeAssets tag in the PackageReference. This stops all Blink runtime binaries from being copied into the output folder. +You can prevent runtime files from being included by restricting the package to **compile-only** assets using the **IncludeAssets** tag in the **PackageReference**. This stops all Blink runtime binaries from being copied into the output folder. Refer to the following package reference: {% tabs %} -{% highlight XAML %} +{% highlight xml %} @@ -1525,23 +1508,23 @@ Refer to the following package reference: {% endhighlight %} {% endtabs %} -By using IncludeAssets="compile", only the required compile-time metadata is included, and all runtime dependencies (BlinkBinaries) are excluded from the final build or publish output. +By using **IncludeAssets="compile"**, only the required compile-time metadata is included, and all runtime dependencies (BlinkBinaries) are excluded from the final build or publish output. N> If you exclude runtime files, you must manually place BlinkBinaries on the server and configure BlinkPath in BlinkConverterSettings for conversion to work. -Exclude BlinkBinaries in .NET Framework Projects +**Exclude BlinkBinaries in .NET Framework Projects** -For .NET Framework applications, Blink runtime files are included through a .targets file referenced in the project. -To exclude BlinkBinaries, simply remove this import entry. +For .NET Framework applications, Blink runtime files are included through a `.targets` file referenced in the project. +To exclude BlinkBinaries, remove this import entry. {% tabs %} -{% highlight XAML %} +{% highlight xml %} {% endhighlight %} {% endtabs %} -Removing this line prevents the Syncfusion® build targets from copying BlinkBinaries and other runtime files into your bin folder during build or publish. +Removing this line prevents the Syncfusion® build targets from copying BlinkBinaries and other runtime files into your `bin` folder during build or publish. N> By excluding BlinkBinaries, you can significantly reduce the size of your deployment package, especially in server environments where disk usage and deployment time matter. \ No newline at end of file