here is the sample code that create the pdf
- Code: Select all
HtmlConverter.Convert(ConfigurationManager.AppSettings["WebURL"] + "GenerateReport/PDF_GenerateTemplate.aspx?code=" + sGUID, ConfigurationManager.AppSettings["HTMLPath"] + testCandidateID + @"\" + sGUID + ".pdf",
//enable javascript
true,
//load timeout
100 * 1000,
//page size
new SizeF(612, 792),
//page margins
new PdfMargins(0, 0));
on the page that get called for the conversion, we have the folowing javascript code in the <head>
- Code: Select all
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {packages: ['corechart'], 'language' : 'fr'});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
// Define the chart to be drawn.
var data = new google.visualization.arrayToDataTable([
["Element", "Density", { role: "style" }],
["comp1",3,"red" ],
["comp2",1,"red" ],
["comp3",2,"red" ],
["comp4",5,"red" ],
]);
var view = new google.visualization.DataView(data);
view.setColumns([0, 1,
{ calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation" },
2]);
var options = {
title: "",
hAxis: {
viewWindowMode: 'explicit',
viewWindow: {min: 0,
max: 5}
},
width: 600,
height: 400,
bar: {groupWidth: "10%"},
legend: { position: "none" },
};
// Instantiate and draw the chart.
var chart_div = document.getElementById('barchart_values');
var chart = new google.visualization.BarChart(chart_div);
google.visualization.events.addListener(chart, 'ready', function () {
chart_div.innerHTML = '<img src="' + chart.getImageURI() + '">';
console.log(chart_div.innerHTML);
});
chart.draw(view, options);
//chart.draw(data, null);
}
</script>
this code does generate a chart and shot it in the page but it never runs before the pdf is compleated