From 6b1b2668de0cb1c9221a563d1bd4fa6e871fd6cc Mon Sep 17 00:00:00 2001 From: Srihariharan Date: Wed, 24 Jan 2024 14:54:57 +0530 Subject: [PATCH 1/2] 866304: Removed the WebKit Html to PDF related UG documentations. --- ...-HTML-to-PDF-in-Azure-App-Service-Linux.md | 2 +- ...TML-to-PDF-in-Azure-App-Service-Windows.md | 125 - ...rt-HTML-to-PDF-in-Azure-Functions-Linux.md | 2 +- ...-HTML-to-PDF-in-Azure-Functions-Windows.md | 138 - File-Formats/PDF/Convert-HTML-To-PDF/IE.md | 12 - .../PDF/Convert-HTML-To-PDF/WebKit.md | 3629 ----------------- File-Formats/PDF/Convert-HTML-To-PDF/azure.md | 4 +- .../Convert-HTML-To-PDF/troubleshooting.md | 74 - File-Formats/PDF/Converting-HTML-to-PDF.md | 57 +- ...HTML-converter-in-Visual-Studio-for-Mac.md | 114 - 10 files changed, 5 insertions(+), 4152 deletions(-) delete mode 100644 File-Formats/PDF/Convert-HTML-To-PDF/Convert-HTML-to-PDF-in-Azure-App-Service-Windows.md delete mode 100644 File-Formats/PDF/Convert-HTML-To-PDF/Convert-HTML-to-PDF-in-Azure-Functions-Windows.md delete mode 100644 File-Formats/PDF/Convert-HTML-To-PDF/WebKit.md delete mode 100644 File-Formats/PDF/How-to-use-the-HTML-converter-in-Visual-Studio-for-Mac.md diff --git a/File-Formats/PDF/Convert-HTML-To-PDF/Convert-HTML-to-PDF-in-Azure-App-Service-Linux.md b/File-Formats/PDF/Convert-HTML-To-PDF/Convert-HTML-to-PDF-in-Azure-App-Service-Linux.md index 01a22257e..188db13fb 100644 --- a/File-Formats/PDF/Convert-HTML-To-PDF/Convert-HTML-to-PDF-in-Azure-App-Service-Linux.md +++ b/File-Formats/PDF/Convert-HTML-To-PDF/Convert-HTML-to-PDF-in-Azure-App-Service-Linux.md @@ -120,7 +120,7 @@ public ActionResult ExportToPDF() //Set command line arguments to run without sandbox. settings.CommandLineArguments.Add("--no-sandbox"); settings.CommandLineArguments.Add("--disable-setuid-sandbox"); - //Assign WebKit settings to the HTML converter + //Assign BlinkConverter settings to the HTML converter htmlConverter.ConverterSettings = settings; //Convert HTML string to PDF PdfDocument document = htmlConverter.Convert("http://www.syncfusion.com"); diff --git a/File-Formats/PDF/Convert-HTML-To-PDF/Convert-HTML-to-PDF-in-Azure-App-Service-Windows.md b/File-Formats/PDF/Convert-HTML-To-PDF/Convert-HTML-to-PDF-in-Azure-App-Service-Windows.md deleted file mode 100644 index 81820baf8..000000000 --- a/File-Formats/PDF/Convert-HTML-To-PDF/Convert-HTML-to-PDF-in-Azure-App-Service-Windows.md +++ /dev/null @@ -1,125 +0,0 @@ ---- -title: Convert HTML to PDF in Azure App Service on Windows | Syncfusion -description: Convert HTML to PDF in Azure App Service on Windows using Syncfusion .NET Core HTML to PDF converter library. -platform: file-formats -control: PDF -documentation: UG ---- - -# Convert HTML to PDF file in Azure App Service on Windows - -The Syncfusion [HTML to PDF converter](https://www.syncfusion.com/document-processing/pdf-framework/net/html-to-pdf) is a .NET library for converting webpages, SVG, MHTML, and HTML to PDF using C#. Using this library, **convert HTML to PDF document in Azure App Service on Windows**. - -## Steps to convert HTML to PDF file in Azure App Service on Windows - -Step 1: Create a new ASP.NET Core Web App (Model-View-Controller). -![Create a ASP.NET Core Web App project](Azure_images/Azure_app_service_windows/Create-net-core-web-app.png) - -Step 2: Create a project name and select the location. -![Configure your new project](Azure_images/Azure_app_service_windows/project_configuration.png) - -Step 3: Click **Create**. -![Additional information](Azure_images/Azure_app_service_windows/Framework_selection.png) - -Step 4: Install the [Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core/) NuGet package to reference your project using the **Package Manager Console**. -![NuGet package installation](Azure_images/Azure_app_service_windows/Package_Manager_Console_Nuget.png) - -N> Starting with v16.2.0.x, if you reference Syncfusion assemblies from the trial setup or NuGet feed, you also have to add the "Syncfusion.Licensing" assembly reference and include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to learn about registering the Syncfusion license key in your application to use our components. - -Step 5: A default action method named Index will be present in *HomeController.cs*. Right-click on the Index method and select **Go To View**, where you will be directed to its associated view page *Index.cshtml*. Add a new button in the *Index.cshtml* as follows. - -{% tabs %} -{% highlight c# tabtitle="C#" %} - -@{ - Html.BeginForm("ExportToPDF", "Home", FormMethod.Get); - { -
- -
- } - Html.EndForm(); -} - -{% endhighlight %} -{% endtabs %} - -Step 6: Include the following namespaces in *HomeController.cs*. - -{% tabs %} -{% highlight c# tabtitle="C#" %} - -using Syncfusion.HtmlConverter; -using Syncfusion.Pdf; - -{% endhighlight %} -{% endtabs %} - -Step 7: Add a new action method named ExportToPDF in the HomeController.cs file and include the following code example to convert HTML to PDF document in *HomeController.cs*. - -{% tabs %} -{% highlight c# tabtitle="C#" %} - -public IActionResult ExportToPDF() -{ - //Initialize HTML to PDF converter. - HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - //Convert URL to PDF. - PdfDocument document = htmlConverter.Convert("https://www.google.com"); - //Saving the PDF to the MemoryStream. - MemoryStream stream = new MemoryStream(); - document.Save(stream); - return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "Sample.pdf"); -} - -{% endhighlight %} -{% endtabs %} - -Step 8: Copy the OpenSSL assemblies and paste them into the **runtimes/win-x64/native** folder containing the HTML_to_PDF_Azure_app_service.csproj file. - -N> The OpenSSL libraries can be installed by downloading their setup from this [link.](https://www.syncfusion.com/downloads/support/directtrac/general/ze/OPENSSL-798051511) - -![Right-click the project and select the publish option](Azure_images/Azure_app_service_windows/runtimes.png) - -Step 9: Set **Copy if newer** for all the OpenSSL assemblies. -![Right-click the project and select the publish option](Azure_images/Azure_app_service_windows/copy_if_newer.png) - -## Steps to publish as Azure App Service on Windows - -Step 1: Right-click the project and select the **Publish** option. -![Right-click the project and select the publish option](Azure_images/Azure_app_service_windows/Publish_button_screenshot.png) - -Step 2: Click **Add a Publish Profile**. -![Click the Add a publish profile](Azure_images/Azure_app_service_windows/Publish_profile_screenshot.png) - -Step 3: Select the publish target as **Azure**. -![Select the publish target as Azure](Azure_images/Azure_app_service_windows/Select_target.png) - -Step 4: Select the Specific target as **Azure App Service (Windows)**. -![Select the publish target](Azure_images/Azure_app_service_windows/Select_azure-app-service-windows.png) - -Step 5: Click the **Create new** option to create a new app service. -![Click create new option](Azure_images/Azure_app_service_windows/Create_new_app_service.png) - -Step 6: Click **Create** to proceed with **App Service** creation. -![Click the create button](Azure_images/Azure_app_service_windows/App_service_details.png) - -Step 7: Click **Finish** to finalize the **App Service** creation. -![Click the finish button](Azure_images/Azure_app_service_windows/Finish_app_service.png) - -Step 8: Click **Close**. -![Create a ASP.NET Core Project](Azure_images/Azure_app_service_windows/profile_creation_success.png) - -Step 9: Click **Publish**. -![Click the Publish button](Azure_images/Azure_app_service_windows/Publish_app_service.png) - -Step 10: Now, Publish has succeeded. -![Publish has been succeeded](Azure_images/Azure_app_service_windows/Publish_link.png) - -Step 11: Now, the published webpage will open in the browser. -![Browser will open after publish](Azure_images/Azure_app_service_windows/WebView.png) - -Step 12: Select a PDF document and click **Export to PDF** to create a PDF document. You will get the output PDF document as follows. -![Create PDF document in Azure App Service on Windows](Azure_images/Azure_app_service_windows/Output_screenshot.png) - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/html-to-pdf-csharp-examples/tree/master/Azure/HTML-to-PDF-Azure-app-service(Windows)). diff --git a/File-Formats/PDF/Convert-HTML-To-PDF/Convert-HTML-to-PDF-in-Azure-Functions-Linux.md b/File-Formats/PDF/Convert-HTML-To-PDF/Convert-HTML-to-PDF-in-Azure-Functions-Linux.md index ed078c592..21ca2c43f 100644 --- a/File-Formats/PDF/Convert-HTML-To-PDF/Convert-HTML-to-PDF-in-Azure-Functions-Linux.md +++ b/File-Formats/PDF/Convert-HTML-To-PDF/Convert-HTML-to-PDF-in-Azure-Functions-Linux.md @@ -58,7 +58,7 @@ Step 5: Add the following code example in the Function1 class to convert HTML to settings.CommandLineArguments.Add("--no-sandbox"); settings.CommandLineArguments.Add("--disable-setuid-sandbox"); settings.BlinkPath = blinkBinariesPath; - //Assign WebKit settings to the HTML converter + //Assign BlinkConverter settings to the HTML converter htmlConverter.ConverterSettings = settings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert(url); diff --git a/File-Formats/PDF/Convert-HTML-To-PDF/Convert-HTML-to-PDF-in-Azure-Functions-Windows.md b/File-Formats/PDF/Convert-HTML-To-PDF/Convert-HTML-to-PDF-in-Azure-Functions-Windows.md deleted file mode 100644 index 5da54d58d..000000000 --- a/File-Formats/PDF/Convert-HTML-To-PDF/Convert-HTML-to-PDF-in-Azure-Functions-Windows.md +++ /dev/null @@ -1,138 +0,0 @@ ---- -title: Convert HTML to PDF in Azure Functions on Windows | Syncfusion -description: Convert HTML to PDF in Azure Functions on Windows using Syncfusion .NET Core HTML to PDF converter library. -platform: file-formats -control: PDF -documentation: UG ---- - -# Convert HTML to PDF file in Azure Functions on Windows - -The Syncfusion [HTML to PDF converter](https://www.syncfusion.com/document-processing/pdf-framework/net/html-to-pdf) is a .NET library for converting webpages, SVG, MHTML, and HTML to PDF using C#. Using this library, **convert HTML to a PDF document in Azure Functions on Windows**. - -## Steps to convert HTML to PDF file in Azure Functions on Windows - -Step 1: Create the Azure functions project. -![Convert HTMLToPDF Azure Functions Step1](Azure_images/Azure_function/AzureFunctions1.png) - -Step 2: Create a project name and select the location. -![Project naming](Azure_images/Azure_function/AzureFunctions2.png) - -Step 3: Select the function worker as .NET 6.0(Long-term support), and the selected HTTP triggers as follows. -![Convert HTMLToPDF Azure Functions Step3](Azure_images/Azure_function/AzureFunctions3.png) - -Step 4: Install the [Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core/) NuGet package as a reference to your project using **Package Manager Console**. -![Convert HTMLToPDF Azure Functions Step4](Azure_images/Azure_function/AzureFunctions4.png) - -N> Starting with v16.2.0.x, if you reference Syncfusion assemblies from the trial setup or NuGet feed, you also have to add the "Syncfusion.Licensing" assembly reference and include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to learn about registering the Syncfusion license key in your application to use our components. - -Step 5: Include the following namespaces in the **Function1.cs** file. - -{% tabs %} -{% highlight c# tabtitle="C#" %} - -using Syncfusion.HtmlConverter; -using Syncfusion.Pdf; - -{% endhighlight %} -{% endtabs %} - -Step 6: Add the following code example in the **Run** method of the **Function1** class to **convert HTML to PDF document** in Azure Functions and return the resultant **PDF document**. - -{% tabs %} -{% highlight c# tabtitle="C#" %} - -[FunctionName("Function1")] -public static async Task Run( - [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, - ILogger log, ExecutionContext context) -{ - MemoryStream ms = new MemoryStream(); - try { - //Initialize HTML to PDF converter. - HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - WebKitConverterSettings settings = new WebKitConverterSettings(); - //Set WebKit path. - settings.WebKitPath = Path.Combine(context.FunctionAppDirectory, "bin/runtimes/win-x64/native"); - //Assign WebKit settings to HTML converter. - htmlConverter.ConverterSettings = settings; - //Convert URL to PDF. - PdfDocument document = htmlConverter.Convert("https://www.google.com"); - - //Save and close the PDF document. - document.Save(ms); - document.Close(); - ms.Position = 0; - } - - catch (Exception ex) { - //Create a new PDF document. - PdfDocument document = new PdfDocument(); - //Add a page to the document. - PdfPage page = document.Pages.Add(); - //Create PDF graphics for the page. - PdfGraphics graphics = page.Graphics; - - //Set the standard font. - PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 5); - //Draw the text. - graphics.DrawString(ex.ToString(), font, PdfBrushes.Black, new Syncfusion.Drawing.PointF(0, 0)); - - //Creating the stream object. - ms = new MemoryStream(); - //Save the document into memory stream. - document.Save(ms); - //Close the document. - document.Close(true); - ms.Position = 0; - } - - HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); - response.Content = new ByteArrayContent(ms.ToArray()); - response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { - FileName = "Sample.pdf" - }; - response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf"); - return response; -} - -{% endhighlight %} -{% endtabs %} - -Step 7: Copy the OpenSSL assemblies and paste them into the **runtimes/win-x64/native** folder containing the HTML_to_PDF_Azure_Functions.csproj file. - -N> The OpenSSL libraries can be installed by downloading their setup from this [link.](https://www.syncfusion.com/downloads/support/directtrac/general/ze/OPENSSL-798051511) - -![Right-click the project and select the publish option](Azure_images/Azure_function/runtimes.png) - -Step 8: Set **Copy if newer** for all the OpenSSL assemblies. -![Right-click the project and select the publish option](Azure_images/Azure_function/copy_if_newer.png) - -Step 9: Right-click the project and select Publish. Then, create a new profile in the Publish Window. -![Create a new profile in the Publish Window](Azure_images/Azure_function/Click_publish.png) - -Step 10: Select the target as **Azure** and click **Next**. -![Select the target as Azure](Azure_images/Azure_function/Set_Azure_target.png) - -Step 11: Select the **Azure Function App (Windows)** and click **Next**. -![Select Azure function app](Azure_images/Azure_function/Select_function_app.png) - -Step 12: Select the **Create new**. -![Configure Hosting Plan](Azure_images/Azure_function/Select_create_new_button.png) - -Step 13: Click **Create**. -![Browser will open after publish](Azure_images/Azure_function/WebView.png) - -Step 14: After creating the function app service, click **Finish**. -![Creating app service](Azure_images/Azure_function/Creating_app_function.png) - -Step 15: Click **Publish**. -![Click the Publish button](Azure_images/Azure_function/Publish_app_function.png) - -Step 16: Now, Publish has succeeded. -![Publish has been succeeded](Azure_images/Azure_function/Publish_link(function).png) - -Step 17: Now, go to the Azure portal and select App Services. After running the service, click **Get function URL > Copy**. Include the URL as a query string in the URL. Then, paste it into a new browser tab. You will get a PDF document as follows. -![Output document screenshot](Azure_images/Azure_function/Output_screenshot.png) - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/html-to-pdf-csharp-examples/tree/master/Azure/HTML-to-PDF-Azure-Functions(Windows)). \ No newline at end of file diff --git a/File-Formats/PDF/Convert-HTML-To-PDF/IE.md b/File-Formats/PDF/Convert-HTML-To-PDF/IE.md index 8572f6ed4..e2555aabb 100644 --- a/File-Formats/PDF/Convert-HTML-To-PDF/IE.md +++ b/File-Formats/PDF/Convert-HTML-To-PDF/IE.md @@ -327,18 +327,6 @@ document.Close(True) You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/IE/Convert-HTML-to-PDF-with-PDFA-conformance). -## Limitations in the IE Rendering Engine - -Syncfusion’s IE HTML to PDF converter relied on Microsoft’s MSHTML library to do the conversion from HTML to PDF. The actual conversion happens in two steps. - -* Convert HTML into a Metafile. -* Rendering the Metafile to PDF. - -The main advantage of this kind of conversion is that the text rendered remains searchable in PDF. -With version 9 of Internet Explorer, Microsoft started using hardware acceleration to produce bitmap images instead of metafiles, completely removing the ability to render selectable or searchable text within PDF. Users can work around the problem by making some registry changes, but may not be satisfied with the result, so a better alternative was needed. Hence a new converter based on the WebKit renderer was created. -The WebKit rendered document contains vector graphics instead of scalar images. This reduces file size and allows users to perform various operations such as text search, selection, and clipboard copy. Apart from overcoming the limitations in the Internet Explorer rendering engine, the new WebKit render also provides better support to render HTML5, CSS3, and SVG content. - - ## Troubleshooting diff --git a/File-Formats/PDF/Convert-HTML-To-PDF/WebKit.md b/File-Formats/PDF/Convert-HTML-To-PDF/WebKit.md deleted file mode 100644 index c6357771a..000000000 --- a/File-Formats/PDF/Convert-HTML-To-PDF/WebKit.md +++ /dev/null @@ -1,3629 +0,0 @@ ---- -title: Converting HTML to PDF with WebKit engine | Syncfusion -description: Learn how to convert HTML to PDF using WebKit rendering engine with various features like TOC, partial web page to PDF etc. -platform: file-formats -control: PDF -documentation: UG ---- -# Conversion using WebKit Rendering - - -Syncfusion Essential PDF supports HTML to PDF conversion by using the advanced Qt WebKit rendering engine. This converter can be easily integrated into any application on .NET platforms such as Windows Forms, WPF, ASP.NET, ASP.NET MVC and ASP.NET Core to convert URLs, HTML string, SVG and MHTML to PDF, and convert other formats like HTML to MHTML, HTML to SVG, and HTML to image. - -Qt WebKit rendering is accurate, and the result preserves all the graphics, images, text, fonts, and the layout of the original HTML document/webpage. - -It does not require external dependencies like browsers, printer drivers, or viewers. - -N> Starting with v20.1.0.x, if you reference Syncfusion HTML converter assemblies from trial setup or from the NuGet feed, you also have to include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to know about registering Syncfusion license key in your application to use our components. - -N> From version 20.1.0.XX, if you are using the WebKit rendering engine from NuGet packages, there is no need to manually copy the QtBinaries folder from the NuGet packages folder. There is also no need to set WebKitPath to the converter settings explicitly. It will copy the QtBinaries to the application bin folder and use the binaries from the bin folder automatically - -## Prerequisites for Windows - -* Latest WebKit HTML converter can be download from the below link, - - [https://www.syncfusion.com/downloads/latest-version](https://www.syncfusion.com/downloads/latest-version) - -* Supports conversion from .NET Framework 2.0 and .NET Core 2.0. - -* To convert HTML to PDF in the application using WebKit rendering engine, the following assemblies or NuGet packages should be added as reference to the project. - -Assemblies - -
- - - - - - - - - - - - -
-Platforms -Assemblies -
.NET Framework -
    -
  • Syncfusion.Compression.Base.dll
  • -
  • Syncfusion.Pdf.Base.dll
  • -
  • Syncfusion.HtmlConverter.Base.dll
  • -
-
.NET Core -
    -
  • Syncfusion.Compression.Portable.dll
  • -
  • Syncfusion.Pdf.Portable.dll
  • -
  • Syncfusion.HtmlConverter.Portable.dll
  • -
-
- - -NuGet - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Platform(s)NuGet Package
-Windows Forms - -{{'[Syncfusion.HtmlToPdfConverter.QtWebKit.WinForms.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.QtWebKit.WinForms/)'| markdownify }} -
-WPF - -{{'[Syncfusion.HtmlToPdfConverter.QtWebKit.Wpf.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.QtWebKit.Wpf/)'| markdownify }} -
-ASP.NET - -{{'[Syncfusion.HtmlToPdfConverter.QtWebKit.AspNet.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.QtWebKit.AspNet/)'| markdownify }} -
-ASP.NET MVC4 - -{{'[Syncfusion.HtmlToPdfConverter.QtWebKit.AspNet.Mvc4.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.QtWebKit.AspNet.Mvc4/)'| markdownify }} -
-ASP.NET MVC5 - -{{'[Syncfusion.HtmlToPdfConverter.QtWebKit.AspNet.Mvc5.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.QtWebKit.AspNet.Mvc5/)'| markdownify }} -
-ASP.NET Core - -{{'[Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core/)'| markdownify }} -
- -N> The above mentioned NuGet packages are available in [nuget.org](https://www.nuget.org/) - - -### VC++ Redistributable - -* WebKit HTML conversion also requires VC++ 2010 redistributable, this should be installed in the machine where the conversion takes place. Please use below download link to get the installer. - - X86 - [https://www.microsoft.com/en-in/download/details.aspx?id=26999](https://www.microsoft.com/en-in/download/details.aspx?id=26999) - - Instead, the required assemblies can be placed in the Windows system folder (for 64-bit machine, it should be place in $SystemDrive\Windows\SysWOW64 and for 32-bit machine, it should be place in $SystemDrive\Windows\System32), - - 1. MSVCP100.dll - 2. MSVCR100.dll - -### OPENSSL - -* For converting HTTPS sites, the HTML converter requires OPENSSL libraries to be installed in the machine where the conversion takes place. The OPENSSL libraries can be installed by downloading its setup from the below link, - - [http://files2.syncfusion.com/dtsupport/directtrac/general/ze/Win32OpenSSL-1_0_1h1593443064.zip](http://files2.syncfusion.com/dtsupport/directtrac/general/ze/Win32OpenSSL-1_0_1h1593443064.zip) - - Instead, the below mentioned assemblies can be placed in the Windows system folder (for 64-bit machine, it should be place in $SystemDrive\Windows\SysWOW64 and for 32-bit machine, it should be place in $SystemDrive\Windows\System32), - - 1. libeay32.dll - 2. libssl32.dll - 3. ssleay32.dll - - -## Prerequisites for Linux - -* Supports conversion from [.NET Core 2.0](https://www.microsoft.com/net/learn/get-started/linux/ubuntu16-04). - -* The latest WebKit HTML converter for Linux can be downloaded as ZIP file from the following link, - - [https://www.syncfusion.com/downloads/latest-version](https://www.syncfusion.com/downloads/latest-version) - -* To convert HTML to PDF in the ASP.NET Core application using WebKit rendering engine, add the following assemblies or NuGet packages as reference to the project. - - Assemblies - 1. Syncfusion.Compression.Portable.dll - 2. Syncfusion.Pdf.Portable.dll - 3. Syncfusion.HtmlConverter.Portable.dll - - NuGet - Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core - -* To convert HTML to PDF in Linux using the WebKit rendering engine, the following packages should be installed in the Linux machine where the conversion takes place. - 1. $ sudo apt-get update - 2. $ sudo apt-get install xvfb - 3. $ sudo apt-get install libssl1.0-dev - 4. $ sudo apt-get install libx11-dev libx11-xcb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-shm0-dev libxcb-util0-dev libxcb-xfixes0-dev libxcb-xkb-dev libxcb1-dev libxfixes-dev libxrandr-dev libxrender-dev - -## Prerequisites for Mac - -* Supports conversion from [.NET Core 2.0](https://www.microsoft.com/net/learn/get-started/macos). - -* The latest WebKit HTML converter for Mac can be downloaded as PKG file from the following link, - - [https://www.syncfusion.com/downloads/latest-version](https://www.syncfusion.com/downloads/latest-version) - -* To convert HTML to PDF in the ASP.NET Core application using WebKit rendering engine, add the following assemblies or NuGet packages as reference to the project. - - Assemblies - 1. Syncfusion.Compression.Portable.dll - 2. Syncfusion.Pdf.Portable.dll - 3. Syncfusion.HtmlConverter.Portable.dll - - NuGet - Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core - - -## WebKitPath - -### Windows - -* The QtBinaries folder is required to convert HTML to PDF with WebKit rendering engine. If the converter is used from NuGet package, there is no need to copy or set this folder path to WebKitPath property in the WebKitConverterSettings. - -* If you are using the HTML to PDF converter from installer or assemblies, then you must set the QtBinaries folder path to WebKitPath property of WebKitConverterSettings. - -* You can get the QtBinaries folder from HTML converter installed location. You can include this folder in your project and set the physical path of the folder to the BlinkPath property. - -Example path: - .NET Framework – ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\QtBinaries). - .NET Core - ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\QtBinariesDotNetCore). - -Please refer below code snippet to set WebKit to the WebKitConverterSettings, - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings settings = new WebKitConverterSettings(); - -//Set WebKit path -settings.WebKitPath = @"/QtBinaries/"; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save and close the PDF document -document.Save("Output.pdf"); -document.Close(true); - -{% endhighlight %} - -{% endtabs %} - -### Linux - -* The QtBinariesLinux folder is required to convert HTML to PDF with WebKit rendering engine. If the converter is used from NuGet package, there is no need to copy or set this folder path to WebKitPath property in the WebKitConverterSettings. - -* The QtBinariesLinux folder is available in the HTML converter Linux build, you can get the folder and set the physical path of the folder to the WebKitPath property of WebKitConverterSettings. - -Please refer below code snippet to set WebKit to the WebKitConverterSettings, - -{% tabs %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings settings = new WebKitConverterSettings(); - -//Set WebKit path -settings.WebKitPath = @"/QtBinariesLinux/"; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -FileStream fileStream = new FileStream("Sample.pdf", FileMode.CreateNew, FileAccess.ReadWrite); - -//Save and close the PDF document -document.Save(fileStream); -document.Close(true); - -{% endhighlight %} - -{% endtabs %} - -### Mac - -* The QtBinariesMac folder is required to convert HTML to PDF with WebKit rendering engine. If the converter is used from NuGet package, there is no need to copy or set this folder path to WebKitPath property in the WebKitConverterSettings. - -* The QtBinariesMac folder is available in the HTML converter Mac build, you can get the folder and set the physical path of the folder to the WebKitPath property of WebKitConverterSettings. - -Please refer below code snippet to set WebKit to the WebKitConverterSettings, - -{% tabs %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings settings = new WebKitConverterSettings(); - -//Set WebKit path -settings.WebKitPath = @"/QtBinariesMac/"; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -FileStream fileStream = new FileStream("Sample.pdf", FileMode.CreateNew, FileAccess.ReadWrite); - -//Save and close the PDF document -document.Save(fileStream); -document.Close(true); - -{% endhighlight %} - -{% endtabs %} - - -## URL to PDF - -To convert website URL or local HTML file to PDF using WebKit rendering engine, please refer the below code snippet. - -N> Ensure that the OPENSSL assemblies are configured properly for converting HTTPS sites. Refer to the pre-requisites section for more information. - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save and close the PDF document -document.Save("Output.pdf"); - -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML to PDF converter -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") - -'Save and close the PDF document -document.Save("Output.pdf") - -document.Close(True) - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -FileStream fileStream = new FileStream("Sample.pdf", FileMode.CreateNew, FileAccess.ReadWrite); - -//Save and close the PDF document -document.Save(fileStream); -document.Close(true); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Convert-website-URL-to-PDF-document). - -## HTML string to PDF - -WebKit HTML converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL. - -baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string. - -For the below 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 below, - -baseURL: C:/Temp/HTMLFiles/ - -To convert the HTML string to PDF, please refer the below code snippet. - - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -//HTML string and Base URL -string htmlText = "\"Syncfusion_logo\"

Hello World

"; - -string baseUrl = @"C:/Temp/HTMLFiles/"; - -//Convert HTML string to PDF -PdfDocument document = htmlConverter.Convert(htmlText, baseUrl); - -//Save and close the PDF document -document.Save("Output.pdf"); - -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML to PDF converter -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -'HTML string and Base URL -Dim htmlText As String = "

Hello World

" - -Dim baseUrl As String = "C:/Temp/HTMLFiles/" - -'Convert HTML string to PDF -Dim document As PdfDocument = htmlConverter.Convert(htmlText, baseUrl) - -'Save and close the PDF document -document.Save("Output.pdf") - -document.Close(True) - -{% endhighlight %} - - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -//HTML string and Base URL -string htmlText = "\"Syncfusion_logo\"

Hello World

"; - -string baseUrl = @"C:/Temp/HTMLFiles/"; - -//Convert HTML string to PDF -PdfDocument document = htmlConverter.Convert(htmlText, baseUrl); - -//Save the document into stream. -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. -document.Close(true); - -//Defining the ContentType for pdf file. -string contentType = "application/pdf"; - -//Define the file name. -string fileName = " Output.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% highlight html %} - - -Syncfusion_logo -

Hello World

- - - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Convert-HTML-string-to-PDF-document). - -## JavaScript - -WebKit HTML converter provides support for enabling or disabling the JavaScript while converting HTML to PDF. Please refer the below code snippet, - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter with WebKit rendering engine -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Disable JavaScript; By default - true -webKitSettings.EnableJavaScript = false; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save the document. -document.Save("Sample.pdf"); - -document.Close(); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter with WebKit rendering engine -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -Dim webKitSettings As New WebKitConverterSettings() - -'Disable JavaScript; By default True -webKitSettings.EnableJavaScript = False - -'Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings - -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") - -'Save the document. -document.Save("Sample.pdf") - -document.Close() - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML converter with WebKit rendering engine -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Disable JavaScript; By default - true -webKitSettings.EnableJavaScript = false; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save the document into stream. -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. -document.Close(true); - -//Defining the ContentType for pdf file. -string contentType = "application/pdf"; - -//Define the file name. -string fileName = " Sample.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Enable-the-JavaScript-while-converting-HTML-to-PDF). - -## Additional delay - -WebKit HTML converter provides option to set the [AdditionalDelay](https://help.syncfusion.com/cr/file-formats/Syncfusion.HtmlConverter.WebKitConverterSettings.html#Syncfusion_HtmlConverter_WebKitConverterSettings_AdditionalDelay), while converting HTML to PDF. Additional delay is the time to wait the converter for loading the external resources (styles, scripts, images, etc.,). Please refer the below code snippet, - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter with WebKit rendering engine -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Set additional delay; units in milliseconds; -webKitSettings.AdditionalDelay = 3000; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save the document. -document.Save("Sample.pdf"); - -document.Close(); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter with WebKit rendering engine -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -Dim webKitSettings As New WebKitConverterSettings() - -'Set additional delay; units in milliseconds; -webKitSettings.AdditionalDelay = 3000 - -'Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings - -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") - -'Save the document. -document.Save("Sample.pdf") - -document.Close() - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML converter with WebKit rendering engine -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Set additional delay; units in milliseconds; -webKitSettings.AdditionalDelay = 3000; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com/"); - -//Save the document into stream. -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. -document.Close(true); - -//Defining the ContentType for pdf file. -string contentType = "application/pdf"; - -//Define the file name. -string fileName = " Sample.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Add-additional-delay-while-converting-HTML-to-PDF). - -## Hyperlinks - -WebKit HTML converter provides support for preserving URL links from HTML to PDF. WebKit HTML converter preserves hyperlinks as Web Link and Document Link annotations in PDF document. Please refer the below code snippet, - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter with WebKit rendering engine -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Enable hyperlinks; By default - true -webKitSettings.EnableHyperLink = false; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save the document. -document.Save("Sample.pdf"); - -document.Close(); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter with WebKit rendering engine -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -Dim webKitSettings As New WebKitConverterSettings() - -'Enable hyperlinks; By default - True -webKitSettings.EnableHyperLink = False - -'Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings - -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") - -'Save the document. -document.Save("Sample.pdf") - -document.Close() - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML converter with WebKit rendering engine -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Enable hyperlinks; By default - true -webKitSettings.EnableHyperLink = false; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save the document into stream. -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. -document.Close(true); - -//Defining the ContentType for pdf file. -string contentType = "application/pdf"; - -//Define the file name. -string fileName = "Sample.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Disable-hyperlink-while-converting-HTML-to-PDF). - -## Bookmarks - -The WebKit HTML Converter provides support for creating bookmarks automatically by enabling [EnableBookmarks](https://help.syncfusion.com/cr/file-formats/Syncfusion.HtmlConverter.WebKitConverterSettings.html#Syncfusion_HtmlConverter_WebKitConverterSettings_EnableBookmarks) property. - -N> The bookmarks are added from the `````` tag, it supports from ```

``` to ```

```. - -Please refer the below code snippet, - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -// WebKit converter settings - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -// Enable bookmarks - -webKitSettings.EnableBookmarks = true; - -//Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings; - -//Convert HTML to PDF - -PdfDocument document = htmlConverter.Convert("input.html"); - -//Save and close the PDF document - -document.Save("Output.pdf"); - -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter - -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -'WebKit converter settings - -Dim webKitSettings As New WebKitConverterSettings() - -'Enable bookmarks - -webKitSettings.EnableBookmarks = True - -'Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings - -'Convert HTML to PDF - -Dim document As PdfDocument = htmlConverter.Convert("input.html") - -'Save and close the document - -document.Save("Output.pdf") - -document.Close() - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -// WebKit converter settings - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -// Enable bookmarks - -webKitSettings.EnableBookmarks = true; - -//Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings; - -//Convert HTML to PDF - -PdfDocument document = htmlConverter.Convert("input.html"); - -//Save the document into stream. - -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. - -document.Close(true); - -//Defining the ContentType for pdf file. - -string contentType = "application/pdf"; - -//Define the file name. - -string fileName = " Output.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. - -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% highlight html %} - - - - - - - -

Syncfusion

- -

Introduction

- Syncfusion is the enterprise technology partner of choice for software development, delivering a broad range of web, mobile, and desktop controls coupled with a service-oriented approach throughout the entire application life cycle. -

Products

-

WEB

- The most comprehensive suite for enterprise web development. -

Desktop

- Comprehensive suite of over 115 components including the fastest chart and grid components. -

Mobile

- Comprehensive suite of components for Xamarin.iOS, Xamarin.Android and Xamarin.Forms including the fastest chart and grid. -

Consulting

- We can build web, mobile, and desktop applications better and faster than anyone since we build on top of our award-winning suite of components and frameworks, saving you time and money. -

Company

-

About us

- Syncfusion has established itself as the trusted partner worldwide for use in mission-critical applications. Founded in 2001 and headquartered in Research Triangle Park, N.C., Syncfusion has more than 12,000 customers, including large financial institutions, Fortune 100 companies, and global IT consultancies. -

contact us

- Morrisville Office - Company Headquarters - 2501 Aerial Center Parkway - Suite 200 - Morrisville, NC 27560 - USA - - - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Create-bookmarks-while-converting-HTML-to-PDF). - -## Table of Contents - -The WebKit HTML Converter provides support for creating a table of contents automatically by using the [EnableToc](https://help.syncfusion.com/cr/file-formats/Syncfusion.HtmlConverter.WebKitConverterSettings.html#Syncfusion_HtmlConverter_WebKitConverterSettings_Toc) property. - -N> TOC are added from the `````` tag, it supports from ```

``` to ```

```. - -Refer to the following code snippet. - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -// WebKit converter settings - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -// Enable table of contents - -webKitSettings.EnableToc = true; - -//Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings; - -//Convert HTML to PDF - -PdfDocument document = htmlConverter.Convert("input.html"); - -//Save and close the PDF document - -document.Save("Output.pdf"); - -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter - -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -'WebKit converter settings - -Dim webKitSettings As New WebKitConverterSettings() - -'Enable table of contents - -webKitSettings.EnableToc = True - -'Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings - -'Convert HTML to PDF - -Dim document As PdfDocument = htmlConverter.Convert("input.html") - -'Save and close the document - -document.Save("Output.pdf") - -document.Close() - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -// WebKit converter settings - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -// Enable table of contents - -webKitSettings.EnableToc = true; - -//Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings; - -//Convert HTML to PDF - -PdfDocument document = htmlConverter.Convert("input.html"); - -//Save the document into stream. - -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. - -document.Close(true); - -//Defining the ContentType for pdf file. - -string contentType = "application/pdf"; - -//Define the file name. - -string fileName = " Output.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. - -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% highlight html %} - - - - - - - -

Syncfusion

- -

Introduction

- Syncfusion is the enterprise technology partner of choice for software development, delivering a broad range of web, mobile, and desktop controls coupled with a service-oriented approach throughout the entire application life cycle. -

Products

-

WEB

- The most comprehensive suite for enterprise web development. -

Desktop

- Comprehensive suite of over 115 components including the fastest chart and grid components. -

Mobile

- Comprehensive suite of components for Xamarin.iOS, Xamarin.Android and Xamarin.Forms including the fastest chart and grid. -

Consulting

- We can build web, mobile, and desktop applications better and faster than anyone since we build on top of our award-winning suite of components and frameworks, saving you time and money. -

Company

-

About us

- Syncfusion has established itself as the trusted partner worldwide for use in mission-critical applications. Founded in 2001 and headquartered in Research Triangle Park, N.C., Syncfusion has more than 12,000 customers, including large financial institutions, Fortune 100 companies, and global IT consultancies. -

contact us

- Morrisville Office - Company Headquarters - 2501 Aerial Center Parkway - Suite 200 - Morrisville, NC 27560 - USA - - - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Creating-TOC-while-converting-HTML-to-PDF). - -### Table of Contents with custom style - -The WebKit HTML Converter provides support for customizing the table of contents style. Each header tag style can be customized by using [HtmlToPdfTocStyle](https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.HtmlToPdf.HtmlToPdfTocStyle.html). Please refer the below code snippet, - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML to PDF converter with WebKit Rendering Engine. - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -//Initialize HTML to PDF converter - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Enable TOC - -webKitSettings.EnableToc = true; - -//Set the style for level 1(H1) items in table of contents - -HtmlToPdfTocStyle tocstyleH1 = new HtmlToPdfTocStyle(); - -tocstyleH1.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 10, PdfFontStyle.Regular); - -tocstyleH1.BackgroundColor = new PdfSolidBrush(new PdfColor(Color.FromArgb(68, 114, 196))); - -tocstyleH1.ForeColor = PdfBrushes.White; - -tocstyleH1.Padding = new PdfPaddings(5, 5, 3, 3); - -webKitSettings.Toc.SetItemStyle(1, tocstyleH1); - -//Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings; - -//Convert HTML to PDF - -PdfDocument document = htmlConverter.Convert("input.html"); - -//Save and close the PDF document - -document.Save("Output.pdf"); - -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML to PDF converter with WebKit Rendering Engine. - -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -'Initialize HTML to PDF converter - -Dim webKitSettings As New WebKitConverterSettings() - -'Enable TOC - -webKitSettings.EnableToc = True - -'Set the style for level 1(H1) items in table of contents - -Dim tocstyleH1 As New HtmlToPdfTocStyle() - -tocstyleH1.Font = New PdfStandardFont(PdfFontFamily.TimesRoman, 10, PdfFontStyle.Regular) - -tocstyleH1.BackgroundColor = New PdfSolidBrush(New PdfColor(Color.FromArgb(68, 114, 196))) - -tocstyleH1.ForeColor = PdfBrushes.White - -tocstyleH1.Padding = New PdfPaddings(5, 5, 3, 3) - -webKitSettings.Toc.SetItemStyle(1, tocstyleH1) - -'Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings - -'Convert HTML to PDF - -Dim document As PdfDocument = htmlConverter.Convert("input.html") -'Save and close the PDF document - -document.Save("Output.pdf") - -document.Close(True) - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML to PDF converter with WebKit Rendering Engine. - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -//Initialize HTML to PDF converter - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Enable TOC - -webKitSettings.EnableToc = true; - -//Set the style for level 1(H1) items in table of contents - -HtmlToPdfTocStyle tocstyleH1 = new HtmlToPdfTocStyle(); - -tocstyleH1.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 10, PdfFontStyle.Regular); - -tocstyleH1.BackgroundColor = new PdfSolidBrush(new PdfColor(Color.FromArgb(68, 114, 196))); - -tocstyleH1.ForeColor = PdfBrushes.Pink; - -tocstyleH1.Padding = new PdfPaddings(5, 5, 3, 3); - -webKitSettings.Toc.SetItemStyle(1, tocstyleH1); - -//Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings; - -//Convert HTML to PDF - -PdfDocument document = htmlConverter.Convert("input.html"); - -//Save the document into stream. - -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. - -document.Close(true); - -//Defining the ContentType for pdf file. - -string contentType = "application/pdf"; - -//Define the file name. - -string fileName = " Output.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. - -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Customize-TOC-while-converting-HTML-to-PDF). - -## MediaType - -WebKit HTML Converter allows selection of media type while converting HTML to PDF. WebKit rendering engine supports Screen and Print media types. Please refer the below code snippet to select Print [MediaType](https://help.syncfusion.com/cr/file-formats/Syncfusion.HtmlConverter.WebKitConverterSettings.html#Syncfusion_HtmlConverter_WebKitConverterSettings_MediaType). - - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter with WebKit rendering engine -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Set print media type -webKitSettings.MediaType = MediaType.Print; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save the document. -document.Save("Sample.pdf"); - -document.Close(); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter with WebKit rendering engine -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -Dim webKitSettings As New WebKitConverterSettings() - -'Set print media type -webKitSettings.MediaType = MediaType.Print - -'Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings - -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") - -'Save the document. -document.Save("Sample.pdf") - -document.Close() - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML converter with WebKit rendering engine -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Set print media type -webKitSettings.MediaType = MediaType.Print; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save the document into stream. -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. -document.Close(true); - -//Defining the ContentType for pdf file. -string contentType = "application/pdf"; - -//Define the file name. -string fileName = " Output.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Selection-of-media-type-while-converting-HTML-to-PDF). - -## HTML Form to PDF Form - -WebKit HTML converter provides support for converting HTML forms to PDF fillable forms. To convert HTML form to PDF form, please refer the below code snippet, - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -// WebKit converter settings - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Set enable form - -webKitSettings.EnableForm = true; - -//Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings; - -//Convert HTML to PDF - -PdfDocument document = htmlConverter.Convert("http://asp.syncfusion.com/demos/http_post_get/default.aspx"); - -//Save and close the PDF document - -document.Save("Output.pdf"); - -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter - -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -'WebKit converter settings - -Dim webKitSettings As New WebKitConverterSettings() - -'Set enable form - -webKitSettings.EnableForm = True - -'Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings - -'Convert HTML to PDF - -Dim document As PdfDocument = htmlConverter.Convert("http://asp.syncfusion.com/demos/http_post_get/default.aspx") - -'Save and close the PDF document - -document.Save("Output.pdf") - -document.Close() - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -// WebKit converter settings - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Set enable form - -webKitSettings.EnableForm = true; - -//Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings; - -//Convert HTML to PDF - -PdfDocument document = htmlConverter.Convert("http://asp.syncfusion.com/demos/http_post_get/default.aspx"); - -//Save the document into stream. - -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document - -document.Close(true); - -//Defining the ContentType for pdf file. - -string contentType = "application/pdf"; - -//Define the file name. - -string fileName = " Output.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. - -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Converting-HTML-form-to-PDF-fillable-forms). - -## Windows Authentication - -The webpage you want to convert may protected with windows authentication. WebKit rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the username and password. Refer to the following code snippet, - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter with WebKit rendering engine -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -webKitSettings.Username = "username"; - -webKitSettings.Password = "password"; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("www.example.com"); - -//Save the document. -document.Save("Sample.pdf"); - -document.Close(); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter with WebKit rendering engine -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -Dim webKitSettings As New WebKitConverterSettings() - -webKitSettings.Username = "username" - -webKitSettings.Password = "password" - -'Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings - -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("www.example.com") - -'Save the document. -document.Save("Sample.pdf") - -document.Close() - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML converter with WebKit rendering engine -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -webKitSettings.Username = "username"; - -webKitSettings.Password = "password"; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("www.example.com"); - -//Save the document into stream. -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. -document.Close(true); - -//Defining the ContentType for pdf file. -string contentType = "application/pdf"; - -//Define the file name. -string fileName = " Output.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Convert-windows-authenticated-webpage-to-PDF-document). - -## Form Authentication - -The WebKit HTML Converter provides support for form authentication by using cookies. The cookies will be send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and a value. Please refer the below code snippet, - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -// WebKit converter settings - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -// Add cookies as name and value pair - -webKitSettings.Cookies.Add("CookieName1", " CookieValue1"); - -webKitSettings.Cookies.Add("CookieName2", " CookieValue2"); - -//Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings; - -//Convert url to pdf - -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save and close the PDF document - -document.Save("Output.pdf"); - -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter - -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -'WebKit converter settings - -Dim webKitSettings As New WebKitConverterSettings() - -'Add cookies - -webKitSettings.Cookies.Add("Name1", "Value1") - -webKitSettings.Cookies.Add("Name2", "Value2") - -'Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings - -'Convert HTML to PDF - -Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com ") - -'Save and close the document - -document.Save("Output.pdf") - -document.Close() - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -// WebKit converter settings - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -// Add cookies as name and value pair - -webKitSettings.Cookies.Add("CookieName1", " CookieValue1"); - -webKitSettings.Cookies.Add("CookieName2", " CookieValue2"); - -//Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings; - -//Convert url to pdf - -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save the document into stream. - -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. - -document.Close(true); - -//Defining the ContentType for pdf file. - -string contentType = "application/pdf"; - -//Define the file name. - -string fileName = " Output.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. - -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Form-authentication-while-converting-HTML-to-PDF). - -## Token based authentication - -The WebKit HTML Converter supports token-based authentication by using the HTTP request headers. The token values will be send to web server when the HTML page is requested. Refer to the following code snippet. - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML to PDF converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings settings = new WebKitConverterSettings(); - -//Add a bearer token to login a webpage - -settings.HttpRequestHeaders.Add("Authorization", "bearer <>"); - -//Assign WebKit settings to HTML converter - -htmlConverter.ConverterSettings = settings; - -//Convert URL to PDF - -PdfDocument document = htmlConverter.Convert("https://www.example.com"); - -//Save and close the PDF document - -document.Save("Output.pdf"); - -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML to PDF converter - -Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -Dim settings As WebKitConverterSettings = New WebKitConverterSettings - -'Add a bearer token to login a webpage - -settings.HttpRequestHeaders.Add("Authorization", "bearer <>") - -'Assign WebKit settings to HTML converter - -htmlConverter.ConverterSettings = settings - -Dim document As PdfDocument = htmlConverter.Convert("https://www.example.com") - -'Save and close the PDF document - -document.Save("Output.pdf") - -document.Close(true) - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML to PDF converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -WebKitConverterSettings settings = new WebKitConverterSettings(); - -//Add a bearer token to login a webpage - -settings.HttpRequestHeaders.Add("Authorization", "bearer <>"); - -//Assign WebKit settings to HTML converter - -htmlConverter.ConverterSettings = settings; - -//Convert URL to PDF - -PdfDocument document = htmlConverter.Convert("https://www.example.com"); - -//Save the document into stream. - -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. - -document.Close(true); - -//Defining the ContentType for pdf file. - -string contentType = "application/pdf"; - -//Define the file name. - -string fileName = " Output.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. - -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Convert-token-based-authenticate-webpage-to-PDF). - -## Offline conversion - -WebKit HTML converter provides support for converting HTML to PDF in offline mode. 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. - -N> If an online URL is tried to convert in offline mode, the converter will generate empty PDF as it will not try to load any resource from online. - -Please refer the below code snippet, - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter with WebKit rendering engine -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Enable offline mode -webKitSettings.EnableOfflineMode = true; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings; - -//Convert HTML to PDF -PdfDocument document = htmlConverter.Convert("input.html"); - -//Save the document. -document.Save("Sample.pdf"); - -document.Close(); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter with WebKit rendering engine -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -Dim webKitSettings As New WebKitConverterSettings() - -'Enable offline mode -webKitSettings.EnableOfflineMode = True - -'Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings - -'Convert HTML to PDF -Dim document As PdfDocument = htmlConverter.Convert("input.html") - -'Save the document. -document.Save("Sample.pdf") - -document.Close() - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML converter with WebKit rendering engine -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Enable offline mode -webKitSettings.EnableOfflineMode = true; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings; - -//Convert HTML to PDF -PdfDocument document = htmlConverter.Convert("input.html"); - -//Save the document into stream. -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. -document.Close(true); - -//Defining the ContentType for pdf file. -string contentType = "application/pdf"; - -//Define the file name. -string fileName = " Output.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Converting-HTML-to-PDF-in-offline-mode). - -## Table Header and Footer - -The WebKit HTML Converter supports repeating html table header and footer on every PDF page. This can be enabled by using [EnableRepeatTableHeader](https://help.syncfusion.com/cr/file-formats/Syncfusion.HtmlConverter.WebKitConverterSettings.html#Syncfusion_HtmlConverter_WebKitConverterSettings_EnableRepeatTableHeader) and [EnableRepeatTableFooter](https://help.syncfusion.com/cr/file-formats/Syncfusion.HtmlConverter.WebKitConverterSettings.html#Syncfusion_HtmlConverter_WebKitConverterSettings_EnableRepeatTableFooter) properties. Please refer the below code snippet, - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -// WebKit converter settings - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -// Enable html table header repeat on every page. - -webKitSettings.EnableRepeatTableHeader = true; - -//Enable html table footer repeat on every page. - -webKitSettings.EnableRepeatTableFooter = true; - -//Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings; - -//Convert URL to PDF - -PdfDocument document = htmlConverter.Convert("input.html"); - -//Save and close the PDF document - -document.Save("Output.pdf"); - -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter - -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -' WebKit converter settings - -Dim webKitSettings As New WebKitConverterSettings() - -' Enable html table header repeat on every page. - -webKitSettings.EnableRepeatTableHeader = True - -'Enable html table footer repeat on every page. - -webKitSettings.EnableRepeatTableFooter = True - -'Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings - -'Convert URL to PDF - -Dim document As PdfDocument = htmlConverter.Convert("input.html") - -'Save and close the PDF document - -document.Save("Output.pdf") - -document.Close(True) - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -// WebKit converter settings - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -// Enable html table header repeat on every page. - -webKitSettings.EnableRepeatTableHeader = true; - -//Enable html table footer repeat on every page. - -webKitSettings.EnableRepeatTableFooter = true; - -//Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings; - -//Convert URL to PDF - -PdfDocument document = htmlConverter.Convert("input.html"); - -//Save the document into stream. - -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. - -document.Close(true); - -//Defining the ContentType for pdf file. - -string contentType = "application/pdf"; - -//Define the file name. - -string fileName = " Output.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. - -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% highlight html %} - - - - - - - -

Repeat Table Header and Footer

- - - - - - - - - - - - - - -
Employee IDSalary
EOLEOL
- - - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Repeating-HTML-table-header-and-footer-in-each-page). - -## HTTP GET and POST - -WebKit HTML Converter provides support for transmitting the parameter to the webpage. There are two methods to access a webpage. By default, WebKit 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 [HttpPostFields](https://help.syncfusion.com/cr/file-formats/Syncfusion.HtmlConverter.WebKitConverterSettings.html#Syncfusion_HtmlConverter_WebKitConverterSettings_HttpPostFields) property. -Please refer the below code snippet to access a web page using HTTP POST, - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -// WebKit converter settings - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Add post parameters - -webKitSettings.HttpPostFields.Add("firstName", "Andrew"); - -webKitSettings.HttpPostFields.Add("lastName", "Fuller"); - -//Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings; - -//Convert HTML to PDF - -PdfDocument document = htmlConverter.Convert("http://asp.syncfusion.com/demos/http_post_get/default.aspx"); - - -//Save and close the PDF document - -document.Save("Output.pdf"); - -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter - -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -'WebKit converter settings - -Dim webKitSettings As New WebKitConverterSettings() - -'Add post parameters - -webKitSettings.HttpPostFields.Add("firstName", "Andrew") - -webKitSettings.HttpPostFields.Add("lastName", "Fuller") - -'Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings - -'Convert HTML to PDF - -Dim document As PdfDocument = htmlConverter.Convert("http://asp.syncfusion.com/demos/http_post_get/default.aspx") - -'Save and close the document - -document.Save("Output.pdf") - -document.Close() - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -// WebKit converter settings - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Add post parameters - -webKitSettings.HttpPostFields.Add("firstName", "Andrew"); - -webKitSettings.HttpPostFields.Add("lastName", "Fuller"); - -//Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings; - -//Convert HTML to PDF - -PdfDocument document = htmlConverter.Convert("http://asp.syncfusion.com/demos/http_post_get/default.aspx"); - -//Save the document into stream. - -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. - -document.Close(true); - -//Defining the ContentType for pdf file. - -string contentType = "application/pdf"; - -//Define the file name. - -string fileName = " Output.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. - -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Access-webpage-using-HTTP-POST). - -Use below code snippet to access a webpage using HTTP GET. - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -string url = "http://asp.syncfusion.com/demos/http_post_get/default.aspx"; - -Uri getMethodUri = new Uri(url); - -string httpGetData = getMethodUri.Query.Length > 0 ? "&" : "?" + String.Format("{0}={1}", "firstName", "Andrew"); - -httpGetData += String.Format("&{0}={1}", "lastName", "Fuller"); - -string urlToConvert = url + httpGetData; - -//Convert HTML to PDF - -PdfDocument document = htmlConverter.Convert(urlToConvert); - -//Save and close the PDF document - -document.Save("Output.pdf"); - -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter - -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -Dim url As String = http://asp.syncfusion.com/demos/http_post_get/default.aspx - -Dim getMethodUri As New Uri(url) - -Dim httpGetData As String = If(getMethodUri.Query.Length > 0, "&", "?" + [String].Format("{0}={1}", "firstName", "Andrew")) - -httpGetData += [String].Format("&{0}={1}", "lastName", "Fuller") - -Dim urlToConvert As String = url & httpGetData - -'Convert HTML to PDF - -Dim document As PdfDocument = htmlConverter.Convert(urlToConvert) - -'Save and close the PDF document - -document.Save("Output.pdf") - -document.Close(True) - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -string url = "http://asp.syncfusion.com/demos/http_post_get/default.aspx"; - -Uri getMethodUri = new Uri(url); - -string httpGetData = getMethodUri.Query.Length > 0 ? "&" : "?" + String.Format("{0}={1}", "firstName", "Andrew"); - -httpGetData += String.Format("&{0}={1}", "lastName", "Fuller"); - -string urlToConvert = url + httpGetData; - -//Convert HTML to PDF - -PdfDocument document = htmlConverter.Convert(urlToConvert); - -//Save the document into stream. - -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. - -document.Close(true); - -//Defining the ContentType for pdf file. - -string contentType = "application/pdf"; - -//Define the file name. - -string fileName = " Output.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. - -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Access-a-webpage-using-HTTP-GET). - -## System proxy - -Please find the steps 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 - -Please refer below screenshots: - -![Manual proxy](htmlconversion_images/proxy.png) - -![Manual proxy settings](htmlconversion_images/proxy2.png) - - -To convert a web page to PDF using system proxy settings, please refer the below code snippet, - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter with WebKit rendering engine -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//To use system proxy settings -webKitSettings.ProxySettings.UseSystemProxy = true; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save the document. -document.Save("Sample.pdf"); - -document.Close(); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter with WebKit rendering engine -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -Dim webKitSettings As New WebKitConverterSettings() - -'To use system proxy settings -webKitSettings.ProxySettings.UseSystemProxy = True - -'Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings - -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") - -'Save the document. -document.Save("Sample.pdf") - -document.Close() - -{% endhighlight %} - -{% endtabs %} - - -## Manual proxy - -To convert a web page to PDF using manual proxy settings, please refer the below code snippet, - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter with WebKit rendering engine -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Set manual proxy settings -webKitSettings.ProxySettings.HostName = "127.0.0.1"; - -webKitSettings.ProxySettings.PortNumber = 8080; - -webKitSettings.ProxySettings.Type = WebKitProxyType.Http; - -webKitSettings.ProxySettings.Username = "username"; - -webKitSettings.ProxySettings.Password = "password"; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save the document. -document.Save("Sample.pdf"); - -document.Close(); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter with WebKit rendering engine -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -Dim webKitSettings As New WebKitConverterSettings() - -'Set manual proxy settings -webKitSettings.ProxySettings.HostName = "127.0.0.1" - -webKitSettings.ProxySettings.PortNumber = 8080 - -webKitSettings.ProxySettings.Type = WebKitProxyType.Http - -webKitSettings.ProxySettings.Username = "username" - -webKitSettings.ProxySettings.Password = "password" - -'Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings - -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") - -'Save the document. -document.Save("Sample.pdf") - -document.Close() - -{% endhighlight %} - -{% endtabs %} - - -## Viewport - -Adjusting HTML content size in PDF is possible by using [WebKitViewPort](https://help.syncfusion.com/cr/file-formats/Syncfusion.HtmlConverter.WebKitConverterSettings.html#Syncfusion_HtmlConverter_WebKitConverterSettings_WebKitViewPort) property of WebKit HTML converter. WebKit viewport size will set to WebKit browser’s window size. -Please refer the below code snippet to adjust WebKit viewport, - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter with WebKit rendering engine -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Set WebKit viewport size -webKitSettings.WebKitViewPort = new Size(800,0); - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save the document. -document.Save("Sample.pdf"); - -document.Close(); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter with WebKit rendering engine -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -Dim webKitSettings As New WebKitConverterSettings() - -'Set WebKit viewport size -webKitSettings.WebKitViewPort = New Size(800, 0) - -'Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings - -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") - -'Save the document. -document.Save("Sample.pdf") - -document.Close() - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML converter with WebKit rendering engine -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -//Set WebKit viewport size -webKitSettings.WebKitViewPort = new Size(800, 0); - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = webKitSettings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("http://www.google.com"); - -//Save the document into stream. -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. -document.Close(true); - -//Defining the ContentType for pdf file. -string contentType = "application/pdf"; - -//Define the file name. -string fileName = "Sample.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Adjust-WebKit-viewport-in-HTML-to-PDF-Conversion). - -## Partial webpage to PDF - -WebKit rendering engine provides support for converting only the part of the HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element by specifying the element ID, refer to the following code snippet. - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -//Convert Partial webpage to PDF -PdfDocument document = htmlConverter.ConvertPartialHtml("input.html", "pic"); - -//Save and close the PDF document -document.Save("Output.pdf"); - -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -'Convert Partial webpage to PDF -Dim document As PdfDocument = htmlConverter.ConvertPartialHtml("input.html", "pic") - -'Save and close the PDF document -document.Save("Output.pdf") - -document.Close(True) - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -//Convert Partial webpage to PDF -PdfDocument document = htmlConverter.ConvertPartialHtml("input.html", "pic"); - -//Save the document into stream -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document -document.Close(true); - -//Defining the ContentType for pdf file -string contentType = "application/pdf"; - -//Define the file name -string fileName = "Sample.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); - -{% endhighlight %} - - -{% highlight html %} - - - - - -Hello world -
- Smiley face
- This is a Syncfusion Logo -
-
- Hello world -
- - - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Converting-partial-webpage-to-PDF-document). - -## HTML to single PDF page - -By using this option, 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. - - 1. FitWidth - 2. FitHeight - -Fit width option: Using this option HTML converter adjust the PDF page height based on the HTML content height. PDF page width remains constant for this option. -Fit height option: Using this option 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. - -Refer to the following code snippet. - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings settings = new WebKitConverterSettings(); - -//Set singlePageLayout option to render the whole HTML content in a single PDF page -settings.SinglePageLayout = SinglePageLayout.FitWidth; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save and close the PDF document -document.Save("Output.pdf"); -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter -Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -Dim settings As WebKitConverterSettings = New WebKitConverterSettings - -'Set singlePageLayout option to render the whole HTML content in a single PDF page -settings.SinglePageLayout = SinglePageLayout.FitWidth - -'Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings - -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") - -'Save and close the PDF document -document.Save("Output.pdf") -document.Close(true) - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -WebKitConverterSettings settings = new WebKitConverterSettings(); - -//Set singlePageLayout option to render the whole HTML content in a single PDF page -settings.SinglePageLayout = SinglePageLayout.FitWidth; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save the document into stream -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document -document.Close(true); - -//Defining the ContentType for pdf file -string contentType = "application/pdf"; - -//Define the file name -string fileName = "Sample.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -## Layout Result - -Getting height of the HTML content in PDF document is possible by using the ```PdfLayoutResult```. Using this result, you can add contents after converting HTML to PDF. Refer to the following code snippet. - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -PdfLayoutResult layoutResult = null; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com", out layoutResult); - -//Draw the text at the end of HTML content -PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 11); - -document.Pages[document.Pages.Count - 1].Graphics.DrawString("End of HTML content", font, PdfBrushes.Red, new PointF(0, layoutResult.Bounds.Bottom)); - -//Save and close the PDF document -document.Save("Output.pdf"); -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter -Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -Dim layoutResult As PdfLayoutResult = Nothing - -Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com", layoutResult) - -Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 11) -document.Pages((document.Pages.Count - 1)).Graphics.DrawString("End of HTML content", font, PdfBrushes.Red, New PointF(0, layoutResult.Bounds.Bottom)) - -'Save and close the PDF document -document.Save("Output.pdf") -document.Close(true) - -{% endhighlight %} - -{% endtabs %} - - -## Windows status - -The windows status can be used instead of addition delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoiding by using windows status. - -N> This feature requires changes in the HTML file. - -If windows status does not match in code and HTML, then the converter will meet with deadlock. -Please refer the below code snippet, - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -// WebKit converter settings - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -// Set windows status. - -webKitSettings.WindowStatus = "completed"; - -//Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings; - -//Convert HTML to PDF - -PdfDocument document = htmlConverter.Convert("input.html"); - -//Save and close the PDF document - -document.Save("Output.pdf"); - -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter - -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -'WebKit converter settings - -Dim webKitSettings As New WebKitConverterSettings() - -'Set windows status. - -webKitSettings.WindowStatus = "completed" - -'Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings - -'Convert HTML to PDF - -Dim document As PdfDocument = htmlConverter.Convert("input.html") - -'Save and close the PDF document - -document.Save("Output.pdf") - -document.Close() - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML converter - -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -// WebKit converter settings - -WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); - -// Set windows status. - -webKitSettings.WindowStatus = "completed"; - -//Assign the WebKit settings - -htmlConverter.ConverterSettings = webKitSettings; - -//Convert HTML to PDF - -PdfDocument document = htmlConverter.Convert("input.html"); - -//Save the document into stream - -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document - -document.Close(true); - -//Defining the ContentType for pdf file - -string contentType = "application/pdf"; - -//Define the file name - -string fileName = "Sample.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name - -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% highlight html %} - - - - - -
- Wait for 2 Seconds -
- - - - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Set-windows-status-while-converting-HTML-to-PDF). - -## Temporary Path - -The WebKit HTML converter internally creates temporary files in the temporary folder to perform the conversion. So, the temporary folder requires read/write/execute permission for the respective user group. - -By default, HTML converter takes system temporary path (C:\Users\<>\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion. If the temporary folder does not have the required permission, then the converter may throw access denied exception. . - -The temporary path can be changed by using the [TempPath](https://help.syncfusion.com/cr/file-formats/Syncfusion.HtmlConverter.WebKitConverterSettings.html#Syncfusion_HtmlConverter_WebKitConverterSettings_TempPath) property of [WebKitConverterSettings](https://help.syncfusion.com/cr/file-formats/Syncfusion.HtmlConverter.WebKitConverterSettings.html). If this property has been set, then the converter use the provided path to perform the conversion. Refer to the following code snippet. - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings settings = new WebKitConverterSettings(); - -//Set Temporary Path to generate temporary files -settings.TempPath = @"C:/HtmlConversion/Temp/"; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save and close the PDF document -document.Save("Output.pdf"); -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter with WebKit rendering engine -Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -Dim settings As WebKitConverterSettings = New WebKitConverterSettings - -'Set Temporary Path to generate temporary files -settings.TempPath = "C:/HtmlConversion/Temp/" - -'Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings - -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") - -'Save and close the PDF document -document.Save("Output.pdf") -document.Close(true) - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -WebKitConverterSettings settings = new WebKitConverterSettings(); - -//Set Temporary Path to generate temporary files -settings.TempPath = @"C:/HtmlConversion/Temp/"; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Save the document into stream. -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document. -document.Close(true); - -//Defining the ContentType for pdf file. -string contentType = "application/pdf"; - -//Define the file name. -string fileName = " Output.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Set-temporary-path-to-perform-conversion). - -## Split Text - -The WebKit HTML converter supports avoiding text split between the PDF pages when converting HTML to PDF. You can prevent the text split by disabling the ```SplitTextLines``` property available in the ```WebKitConverterSettings```.Refer to the following code snippet. - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings settings = new WebKitConverterSettings(); - -//Set the SplitTextLines property -settings.SplitTextLines = false; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("input.html"); - -//Save and close the PDF document -document.Save("Output.pdf"); -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter with WebKit rendering engine -Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -Dim settings As WebKitConverterSettings = New WebKitConverterSettings - -'Set SplitTextLines property -settings.SplitTextLines = false - -'Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings - -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("input.html") - -'Save and close the PDF document -document.Save("Output.pdf") -document.Close(true) - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -WebKitConverterSettings settings = new WebKitConverterSettings(); - -//Set SplitTextLines property -settings.SplitTextLines = false; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("input.html"); - -//Save the document into stream -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document -document.Close(true); - -//Defining the ContentType for pdf file. -string contentType = "application/pdf"; - -//Define the file name -string fileName = " Output.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Avoiding-text-split-between-the-PDF-pages). - -## Split image - -The WebKit HTML converter supports avoiding image split between the PDF pages when converting HTML to PDF. You can prevent the image split by disabling the ```SplitImages``` property available in the ```WebKitConverterSettings```. Refer to the following code snippet. - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings settings = new WebKitConverterSettings(); - -//Set the SplitImages property -settings.SplitImages = false; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("input.html"); - -//Save and close the PDF document -document.Save("Output.pdf"); -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} - -'Initialize HTML converter with WebKit rendering engine -Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) - -Dim settings As WebKitConverterSettings = New WebKitConverterSettings - -'Set the SplitImages property -settings.SplitImages = false - -'Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings - -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("input.html") - -'Save and close the PDF document -document.Save("Output.pdf") -document.Close(true) - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); - -WebKitConverterSettings settings = new WebKitConverterSettings(); - -//Set the SplitImages property -settings.SplitImages=false; - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("input.html"); - -//Save the document into stream -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -stream.Position = 0; - -//Close the document -document.Close(true); - -//Defining the ContentType for pdf file -string contentType = "application/pdf"; - -//Define the file name -string fileName = " Output.pdf"; - -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); - -{% endhighlight %} - -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/WebKit/Avoid-image-split-between-the-PDF-pages). - -## Troubleshooting - - - - - - - - - - - - - - - - - -
ExceptionWebKit assemblies are missing
Reason -When QtBinaries are not available in the WebKitPath mentioned location. -
Solution -Set the path of the QtBinaries folder to the WebKitPath property of WebKitConverterSettings. -

-(Or) -

-Place the QtBinaries folder in bin folder of the project. (This option is only applicable for .NET Framework projects. The WebKitPath property should be set explicitly for .NET Core projects.) -

-The QtBinaries will be available in the WebKitHTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\WebKitHTMLConverter\xx.x.x.xx\QtBinaries) - -
Mapping QtBinaries in Web Application -{% highlight c# tabtitle="C#" %} - -//To refer QtBinaries from Project location -settings.WebKitPath = Server.MapPath("QtBinaries"); - -//or - -// To refer QtBinaries from bin folder of the Project -settings.WebKitPath = Server.MapPath("~/bin/QtBinaries"); - -{% endhighlight %} - -
- - - - - - - - - - - - - -
ExceptionUnable to load DLL 'Syncfusion.WebKitWrapper.dll': The specified module could not be found.
Reason -When VC++ 2010 redistributable is not present in the machine where the conversion take place. -
Solution -Install the VC++ and OpenSSL packages from the below mentioned download links, -

-X86, X64- https://www.microsoft.com/en-us/download/details.aspx?id=26999 -

-Instead, the required assemblies can be added in the Windows system folder. -(for 64-bit machine, it should be place in $SystemDrive\Windows\SysWOW64 and - for 32-bit machine, it should be place in $SystemDrive\Windows\System32), -

-
    -
  • MSVCP100.dll
  • -
  • MSVCR100.dll
  • -
- -
- -Syncfusion provides troubleshooting utility tool to find out the missing prerequisites. The tool is available in the HTML converter installed location: ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\WebKitUtility) - -If the HTML converter installer is not installed in your machine, you can get the troubleshooting utility tool from the following link, - -TroubleshootingTool - -Steps to run the troubleshooting tool. -
    -
  1. Run the Troubleshooting tool application from the HTMLConverter installed location or from the download folder.
  2. -TroubleShootingTool Location -
    -
  3. Download and extract the Dependency Walker files into this root directory. If you need to find the dependency missing issue.
  4. -TroubleShootingTool Dependency -
    -
  5. Click the Check requisites button to start analyzing the requisites required for the HTML to PDF conversion using the WebKit rendering engine.
  6. -TroubleShootingTool -
    -
  7. After checking all the requisites, you can find the success and failure categories from the troubleshooting result window.
  8. -TroubleShootingTool Result -
    -
  9. Finally, the troubleshooting logs will be stored in a text file on an application folder location. You can check the logs with issues and solutions.
  10. -TroubleShootingTool Log -
-If the provided solutions did not resolve the issue, please contact Syncfusion support with troubleshooting logs and the screenshot. - -Please follow the below instructions for manual troubleshooting. - - - - - - - -
WebKit Converter may create PDF with blank pages under the following cases -
- - - - - - - - - - -
Reason - -When the web page (html) is not available/accessible -
Solution -Please check the Internet connection and if the HTML page is available in the mentioned location. -
- - - - - - - - - - -
Reason - -When OpenSSL package is not installed in the machine. -
Solution - -For converting HTTPS sites, it requires OPENSSL libraries to be installed in the machine. The OPENSSL library can be installed by downloading its setup from the below link, -

-OpenSSL - -

-Instead, the required assemblies can added in the Windows system folder (for 64 bit machine, it should be place in

$SystemDrive\Windows\SysWOW64

and for 32 bit machine, it should be place in

$SystemDrive\Windows\System32

), -

-
    -
  • libeay32.dll
  • -
  • libssl32.dll
  • -
  • ssleay32.dll
  • -
-
- - - - - - - - - - -
Reason - -When OpenSSL (libssl) shared objects are not added in Linux docker 3.0 or above. -
Solution - -For converting HTTPS sites in Linux docker 3.0 or above, the HTML converter requires OPENSSL (libssl) shared objects to be placed in the QtBinariesLinux folder . The OPENSSL shared object files can be downloaded from the below link, -

-LibSSL - -

-Instead, the above attached shared object files can be copied to this linux system folder /usr/lib/x86_64-linux-gnu by using below command in docker file, -

- - - - -
-COPY /libssl/ /usr/lib/x86_64-linux-gnu/ -
-
- -
- - - - - - - - - - - - - - - - - - - - -
-Issue -Images or other contents in the HTML are missing in the resultant PDF document -
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. -
Solution -To overcome this issue, add suitable delay for the conversion using AdditionalDelay property of the HTMLConverter. -
Reason -While converting HTML string to PDF, the invalid resource path (Base URL). -
Solution -This can be overcome by passing the valid base URL (path of the resources) along with HTML string. -
- - - - - - - - - - - - -
Issue -HTML conversion fails in Azure website, but it works in development machine. -
Reason -HTML conversion may fail in Azure website due to the lack of administrator privilege and few other restrictions on Free or Shared hosting plan of Azure website. -
Solution -To overcome this failure, use Basic hosting plan or above. If the website is already hosted under Free or Shared hosting plan, this can be scaled up to Basic or above in the Azure portal. -
- - - - - - - - - - - - -
Issue -Text preservation issue in HTML to PDF conversion with Windows Docker using .NET Framework. -
Reason -This issue may occurs due to missing of fonts in docker container. -
Solution -To overcome this issue, you have to add the required fonts to docker container’s fonts directory. Kindly follow the below steps to resolve the text preservation issue in HTML to PDF conversion, -
- 1. Add the required TrueType fonts (.ttf files) in your project.You need to add all the required/used fonts to the docker image. Otherwise, the text may not preserve properly. -
- 2. Copy the files from your project directory to docker containers font directory (C:\Windows\Fonts). -
- 3. Then we need to update the font details in docker image registry. -
-
    -
  • Open the PowerShell window of docker container.
  • -
  • Go to the fonts directory in your project.
  • -
  • Run the below command in PowerShell window to update the font in registry.
  • -
    - - - - -
    - Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" -name "Times New Roman (TrueType)" -value "times.ttf" -type STRING -
    - Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" -name "Arial (TrueType)" -value "arial.ttf" -type STRING -
    -
    -
    -
  • After updating the fonts in registry, the text will be preserved properly.
  • -
-
-N> If you are using web fonts in HTML file/URL, then there is no need to install the fonts in docker. The HTML converter will automatically get the fonts from the URL and embeds it to the PDF document. So the text with web fonts will preserve without adding the fonts to docker image. - -
- - - - - - - - - - - - - - - - - -
HTML conversion support in Azure
Azure App ServiceYes (Except Free/Shared plan)
Azure FunctionsYes (Except consumption plan)
Azure Cloud ServiceYes
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Issue -Failed to convert Webpage Exception in Server -
Reason -If the Syncfusion.HtmlConverter.Base.dll assembly is blocked in the machine, then the converter may throw this exception. -
Solution -Unblock the assembly if it is blocked by referring to the following screenshot of Syncfusion.HtmlConverter.Base.dll. -
-Syncfusion.HtmlConverter.Base.dll Properties -
Reason -This exception may occur if the assemblies and QtBinaries are used from different version of WebKit installers. -
Solution -Make sure to use the Syncfusion assemblies and QtBinaries from the same WebKit Installer since there will be some changes in the assemblies and QtBinaries for every release.The assemblies and QtBinaries for a specific version can be get by installing the WebKit HTML converter. -

-WebKit HTML converter: https://www.syncfusion.com/downloads/version-history -
Reason -While converting HTML to PDF, WebKit HTML converter internally creates temporary files in temp folder for conversion. -

-If the temporary folder does not have elevated permission for the respective user then the WebKit HTML converter may throw this exception. -
Solution -By default, WebKit HTML converter gets system temporary folder to create temporary files for conversion. Please refer to the following examples of default temporary folder. -

-
    -
  • C:\Users\User_Name\AppData\Local\Temp
  • -
  • C:\Windows\Temp
  • -
-
-Make sure that the previous paths have elevated permission for respective user. -

(Or)

-The WebKit HTML converter has support for setting 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. Refer below code snippet to set temp folder. - -{% highlight c# tabtitle="C#" %} - -WebKitConverterSettings settings = new WebKitConverterSettings(); -settings.TempPath = "D://MyProject//bin"; - -{% endhighlight %} - -
Reason -Sometimes exception occurs even if the user have elevated permission -
Solution -Try hosting an application in different user account of the server and check the conversion. -
Reason -WebKit HTML converter may throw this exception if the Web Application is published in a network shared location. -
Solution -To avoid this exception, publish the application in the server’s local disk, where it will be hosted. Please do not publish the website to shared network location. -
Reason -WebKit rendering engine internally creates surrogate process in a temporary folder (temporary executable with different name for every conversion) and launches it for converting HTML to PDF. So, the converter requires read/write/execute permission for temporary folder to execute the temporary executable from the code. -
-
-
    -
  • Server may block the temporary executables due to group policy/Third Party Software. -
  • -
  • The temporary path may do not have the required (read/write/execute) permission. -
  • -
-
Solution -1.The temporary executables can be whitelisted in the server by the following ways: -
-
-
    -
  • Set the path of a folder in server as the temporary executables path by setting the TempPath property of WebkitConverterSettings and add that folder’s path in the exception list of group policy/Third Party Softwares. -{% highlight c# tabtitle="C#" %} - -//Set temporary path to generate temporary files -webkitConverterSettings.TempPath = @"C:/HtmlConversion/Temp/"; - -{% endhighlight %} -
  • -
  • Set a name for the executable in the server by setting TempFileName property of WebkitConverterSettings and add that name in the exception list of group policy/Third Party Softwares. -{% highlight c# tabtitle="C#" %} - -//Set temporary file name to generate temporary files -webkitConverterSettings.TempFileName = "Syncfusion"; - -{% endhighlight %} -
  • -
-2. Enable the read/write/execute permission of the temporary path for the respective group. -
Reason -Sometimes this exception occurs for only particular URL -
Solution -Please contact Syncfusion support with input HTML, code snippet, and environment details (OS, culture settings, bit version etc.,). -
diff --git a/File-Formats/PDF/Convert-HTML-To-PDF/azure.md b/File-Formats/PDF/Convert-HTML-To-PDF/azure.md index d4133dc7d..77c68ac0d 100644 --- a/File-Formats/PDF/Convert-HTML-To-PDF/azure.md +++ b/File-Formats/PDF/Convert-HTML-To-PDF/azure.md @@ -93,7 +93,7 @@ public ActionResult ExportToPDF() //Set command line arguments to run without sandbox. settings.CommandLineArguments.Add("--no-sandbox"); settings.CommandLineArguments.Add("--disable-setuid-sandbox"); - //Assign WebKit settings to the HTML converter + //Assign BlinkConverter settings to the HTML converter htmlConverter.ConverterSettings = settings; //Convert HTML string to PDF PdfDocument document = htmlConverter.Convert("http://www.syncfusion.com"); @@ -308,7 +308,7 @@ Step 5: Add the following code example in the Function1 class to convert HTML to settings.CommandLineArguments.Add("--no-sandbox"); settings.CommandLineArguments.Add("--disable-setuid-sandbox"); settings.BlinkPath = blinkBinariesPath; - //Assign WebKit settings to the HTML converter + //Assign BlinkConverter settings to the HTML converter htmlConverter.ConverterSettings = settings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert(url); diff --git a/File-Formats/PDF/Convert-HTML-To-PDF/troubleshooting.md b/File-Formats/PDF/Convert-HTML-To-PDF/troubleshooting.md index 271e26aa6..645c674d0 100644 --- a/File-Formats/PDF/Convert-HTML-To-PDF/troubleshooting.md +++ b/File-Formats/PDF/Convert-HTML-To-PDF/troubleshooting.md @@ -283,51 +283,6 @@ settings.TempPath = "D://MyProject//bin"; -## Failed to convert Webpage Exception - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Reason -The exception may occur in Windows 7/Windows server 2008 environment due to limitation of ClientWebSocket implementation. -
Solution -To overcome the exception in Windows 7/Windows server 2008 environment, add the System.Buffers.4.5.0 NuGet package in the sample for conversion. -
Reason -Including both packages (Blink and Webkit) in the application might lead to the occurrence of the exception. -
Solution -In order to resolve the exception, it's necessary to eliminate one of the packages (Webkit or Blink) from the application and then perform a thorough cleaning and rebuilding process. -
Reason -Sometimes this exception occurs for only particular URL -
Solution -Please contact Syncfusion support with input HTML, code snippet, and environment details (OS, culture settings, bit version etc.,). -
- ## Blink converter may create PDF with blank pages @@ -612,35 +567,6 @@ Refer to the following package reference:
-## Image rendering issue occurs while converting HTML to PDF using WebKit - - - - - - - - - - - - - - -
Issue -Image rendering issue occurs while converting HTML(HTTPS sites) to PDF using Webkit rendering engine in location machine/Azure App Service. -
Reason -When the OPENSSL assemblies are missing in your machine. -
Solution - -Our WebKit rendering engine necessitates OPENSSL assemblies to access resources from HTTPS URLs. If your project involves accessing resources from HTTPS sites, please make sure to include the following assemblies, -

-ExcludeAssets

-You can get the OPENSSL assemblies from the below link, -https://www.syncfusion.com/downloads/support/directtrac/general/ze/OPENSSL-798051511 -

-
- ## Failed to convert Webpage exception with Linux docker in Mac M1 machine. diff --git a/File-Formats/PDF/Converting-HTML-to-PDF.md b/File-Formats/PDF/Converting-HTML-to-PDF.md index daeb958d4..97612529b 100644 --- a/File-Formats/PDF/Converting-HTML-to-PDF.md +++ b/File-Formats/PDF/Converting-HTML-to-PDF.md @@ -1,6 +1,6 @@ --- title: Converting HTML to PDF | Syncfusion -description: Learn how to convert HTML to PDF using 3 different 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 3 different rendering engines (Blink and IE) with various features like TOC, partial web page to PDF etc. platform: file-formats control: PDF documentation: UG @@ -265,61 +265,6 @@ Refer to [this](/file-formats/pdf/convert-html-to-pdf/features) section for more Refer to [this](/file-formats/pdf/convert-html-to-pdf/troubleshooting) section for troubleshooting HTML to PDF conversion failures and frequently asked questions. -## Steps to disable WebKit warning while performing HTML to PDF - -By default, the PDF document generated with the WebKit rendering engine comes with the following warning message. - -WebKitWarning - -Please refer to the below code snippet to use the DisableWebKitWarning API to remove the default WebKit warning message from the PDF document. - -{% tabs %} - -{% highlight c# tabtitle="C#" %} - -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); -//Initialize the WebKit converter settings -WebKitConverterSettings settings = new WebKitConverterSettings(); -//Disable WebKit warning message -settings.DisableWebKitWarning = true; -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings; -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); -FileStream fileStream = new FileStream("Sample.pdf", FileMode.CreateNew, FileAccess.ReadWrite); - -//Save and close the PDF document -document.Save(fileStream); -document.Close(true); - -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET" %} -'Initialize the HTML to PDF converter -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit) -Dim settings As New WebKitConverterSettings() -'Disable Default WebKit Warning Message -settings.DisableWebKitWarning = true -'Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") - -'Save and close the PDF document -document.Save("Output.pdf") -document.Close(True) - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} -//Currently, IE rendering engine does not support conversion in .NET Core platform -{% endhighlight %} - -{% endtabs %} - -N>Please try our [Blink](https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf) engine for best quality and accuracy in HTML to PDF conversion. - ## Steps to disable IE warning while performing HTML To PDF using the IE rendering engine By default, the PDF document generated with the IE rendering engine comes with the following warning message. diff --git a/File-Formats/PDF/How-to-use-the-HTML-converter-in-Visual-Studio-for-Mac.md b/File-Formats/PDF/How-to-use-the-HTML-converter-in-Visual-Studio-for-Mac.md deleted file mode 100644 index fb06baa23..000000000 --- a/File-Formats/PDF/How-to-use-the-HTML-converter-in-Visual-Studio-for-Mac.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -title: How to use the HTML converter in Visual Studio for Mac | Syncfusion -description: Learn how to use the HTML converter in Visual Studio for Mac with easy steps using Syncfusion .NET Core PDF library. -platform: file-formats -control: PDF -documentation: UG -keywords: Assemblies ---- -# How to use the HTML converter in Visual Studio for Mac. - -In your ASP.NET Core application, add the following assemblies to use Essential HTML Converter: - -* Syncfusion.Compression.Portable.dll -* Syncfusion.Pdf.Portable.dll -* Syncfusion.HtmlConverter.Portable.dll - -For more details, refer to this [Assemblies Required](/File-Formats/PDF/Assemblies-Required) documentation. - -## Steps to convert HTML to PDF using WebKit in ASP.NET Core Mac - -Create a new C# ASP.NET Core Web Application project. -![SampleCreation1](Convert-HTML-To-PDF/htmlconversion_images/SampleCreation1.png) - -Select the Target Framework of your project. -![SampleCreation2](Convert-HTML-To-PDF/htmlconversion_images/SampleCreation2.png) - -Configure your application and click Create. -![SampleCreation3](Convert-HTML-To-PDF/htmlconversion_images/SampleCreation3.png) - -Install the [Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core/) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org/). -![SampleCreation4](Convert-HTML-To-PDF/htmlconversion_images/SampleCreation4.png) - -Copy the QtBinariesMac folder from the installed HtmlToPdfConverter package and paste it into the folder which contains the HTMLtoPDF.csproj file. -![SampleCreation5](Convert-HTML-To-PDF/htmlconversion_images/SampleCreation5.png) - -A default controller with name HomeController.cs gets added on creation of ASP.NET MVC project. Include the following namespaces in that HomeController.cs file. - -{% highlight c# tabtitle="C#" %} - -using Syncfusion.Pdf; -using Syncfusion.HtmlConverter; -using System.IO; -using Microsoft.AspNetCore.Hosting; - -{% endhighlight %} - -A default action method named Index will be present in HomeController.cs. Right click on Index method and select Go To View where you will be directed to its associated view page Index.cshtml. - -Add a new button in the Index.cshtml as shown below. - -{% highlight html %} - -@{Html.BeginForm("ExportToPDF", "Home", FormMethod.Post); -{ -
- -
-} -Html.EndForm(); -} -{% endhighlight %} - -Add a new action method ExportToPDF in HomeController.cs and include the below code snippet to convert HTML to PDF file and download it. - -{% highlight c# tabtitle="C#" %} - -//To get content root path of the project -private readonly IHostingEnvironment _hostingEnvironment; -public HomeController(IHostingEnvironment hostingEnvironment) -{ - _hostingEnvironment = hostingEnvironment; -} - -public IActionResult ExportToPDF() -{ -//Initialize HTML to PDF converter -HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); - -WebKitConverterSettings settings = new WebKitConverterSettings(); - -//Set WebKit path -settings.WebKitPath = Path.Combine(_hostingEnvironment.ContentRootPath, "QtBinariesMac"); - -//Assign WebKit settings to HTML converter -htmlConverter.ConverterSettings = settings; - -//Convert URL to PDF -PdfDocument document = htmlConverter.Convert("https://www.google.com"); - -//Saving the PDF to the MemoryStream -MemoryStream stream = new MemoryStream(); - -document.Save(stream); - -//Download the PDF document in the browser -return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "Output.pdf"); - -} - -{% endhighlight %} - -![SampleCreation6](Convert-HTML-To-PDF/htmlconversion_images/SampleCreation6.png) - -Right click the project and select Build. -![SampleCreation7](Convert-HTML-To-PDF/htmlconversion_images/SampleCreation7.png) - -After Build succeeded. Run the application. -![SampleCreation8](Convert-HTML-To-PDF/htmlconversion_images/SampleCreation8.png) - -A complete working sample can be downloaded from [HtmlToPDF.zip](https://www.syncfusion.com/downloads/support/directtrac/general/ze/HtmlToPDF-545793311) - - -By executing the program, you will get the PDF document as follows. -![SampleCreation9](Convert-HTML-To-PDF/htmlconversion_images/SampleCreation9.png) From 2e09ee2b0ec4b3ff7b4fbda246da63ca8d34a313 Mon Sep 17 00:00:00 2001 From: Srihariharan Date: Wed, 24 Jan 2024 16:33:03 +0530 Subject: [PATCH 2/2] 866304 : Update rendering engine count details. --- File-Formats/PDF/Converting-HTML-to-PDF.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/File-Formats/PDF/Converting-HTML-to-PDF.md b/File-Formats/PDF/Converting-HTML-to-PDF.md index 97612529b..07259ef1b 100644 --- a/File-Formats/PDF/Converting-HTML-to-PDF.md +++ b/File-Formats/PDF/Converting-HTML-to-PDF.md @@ -1,6 +1,6 @@ --- title: Converting HTML to PDF | Syncfusion -description: Learn how to convert HTML to PDF using 3 different rendering engines (Blink and IE) with various features like TOC, partial web page to PDF etc. +description: Learn how to convert HTML to PDF using 2 different rendering engines (Blink and IE) with various features like TOC, partial web page to PDF etc. platform: file-formats control: PDF documentation: UG