Thanks in advance..
I am creating a pdf from html using iText7 and in that html I am creating a chart on canvas
with chart.js. All these are in memory in c# service where I can not use Chrome or any browser library with selenium.
I want to generate chart on canvas with dynamic data in html string. I have tried Jint but not able to succeed. Below is what I have tried -
// Parse HTML
var parser = new HtmlParser();
var document = parser.ParseDocument(htmlStr);
// Get all <script> tags
var scriptTags = document.QuerySelectorAll("script");
// Execute JavaScript in each <script> tag
//var engine = new Engine()
var engine = new Engine(options => options.AllowClr());
engine.Execute(File.ReadAllText("charthtml/js/chart.min.js"));
engine.SetValue("document", document);
foreach (var scriptTag in scriptTags)
{
var scriptCode = scriptTag.InnerHtml;
var result = engine.Evaluate(scriptCode, htmlStr);
if (result.Type == Types.Object)
{
scriptTag.InnerHtml = result.ToString();
}
}
// Return modified HTML
replacedevaluatedHtml = document.DocumentElement.OuterHtml;
Please guide me here. I am thinking that using JINT, I am not able to generate chart on html5 canvas element (correct me if I am wrong). I am open to use any other open source