Articles in this section
Category / Section

How to convert EJ2 charts page into PDF document using Blink?

4 mins read

Syncfusion® HTML to PDF for .NET is used to convert webpages, SVG, MHTML, and HTML to PDF. Using this library, you can convert EJ2 chart page to PDF in Blink using .NET Core.

 

Steps to convert EJ2 chart page to PDF in Blink using .net core programmatically:

  1. Create a new ASP.NET Core MVC application.

Configure a ASP.Net Web application

  1. Install the Syncfusion.HtmlToPdfConverter.Blink.Net.Core.Windows NuGet package as reference to your .NET Core application from NuGet.org

Install NuGet package screenshot

 

  1. Add a new button in Index.cshtml for converting HTML to PDF.
    @{Html.BeginForm("ConvertToPDF", "Home", FormMethod.Post);
    {
    <input type="submit" class="Button" value="Convert To PDF" />
    }}
    

 

  1. Include the following namespaces and code snippet for converting EJ2 chart page to PDF in Homecontroller.cs file.

C#:

using Syncfusion.HtmlConverter;
using Syncfusion.Pdf;
using System.IO;
using Microsoft.AspNetCore.Hosting;

 

//To get content root path of the project
private readonly IHostingEnvironment _hostingEnvironment;
public HomeController(IHostingEnvironment hostingEnvironment)
{
   _hostingEnvironment = hostingEnvironment;
}
 
Public IActionResult ConvertToPDF()
{
 HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
 
 //Initialize the blink converter settings
BlinkConverterSettings settings = new BlinkConverterSettings();
//Set Blink path
settings.BlinkPath = @"../BlinkBinariesWindows/";
//Assign Blink Converter settings to HTML converter
htmlConverter.ConverterSettings = settings;
//Set additional delay; units in milliseconds;
settings.AdditionalDelay = 5000;
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert(@"../ChartToPDF.html");
MemoryStream stream = new MemoryStream();
//Save and close the PDF document 
document.Save(stream);
document.Close(true);
return File(stream.ToArray(), "application/pdf", "Output.pdf");
}
 
 

 

A complete working sample can be downloaded from ChartToPDFSample.zip

 

By executing the above sample, you will get the PDF document as follows.

output pdf webview screenshot

 

output pdf screenshot

 

Take a moment to peruse the documentation for Converting HTML to PDF, where you will find various options for URL to PDF, HTML string to PDF, and Hyperlinks.

 

Note:

Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message.

 

Conclusion:

I hope you enjoyed learning about how to convert EJ2 charts page into PDF document using Blink.

 

You can refer to our Flutter PDF feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our Flutter PDF Flutter PDF examples to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to explore our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you! 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied