i'm trying to export charts created with googles api to pdf, using abcpdf.
i've tried the solution from these questions
but neither works, and i get nothing created from the javascript.
the page i'm trying to render as pdf is
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="boop.aspx.cs" Inherits="boop" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1.0', { 'packages': ['corechart'] });
document.addEventListener("DOMContentLoaded", function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
['Mushrooms', 3],
['Onions', 1],
['Olives', 1],
['Zucchini', 1],
['Pepperoni', 2]
]);
var options = {
'title': 'How Much Pizza I Ate Last Night',
'width': 400,
'height': 300
};
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
});
</script>
</head>
<body >
<form id="form1" runat="server">
<div id="chart_div"></div>
</form>
<asp:Label Text="hej" runat="server" />
</body>
</html>
when i access the page in the browser the chart is rendered, confirming that the COMContentLoaded even triggers the function.
the code where i want to save the chart as a pdf
Doc theDoc = new Doc();
theDoc.HtmlOptions.Timeout = 10000;
theDoc.HtmlOptions.UseScript = true;
theDoc.AddImageUrl("http://localhost:57833/boop.aspx");
theDoc.Save(Server.MapPath("img/htmlimport.pdf"));
theDoc.Clear();
my current code is a bit of a mixup from my previous effords using the beforementioned answers, without success. all i get in the pdf is my static label text.
i'm using abc.pdf8.
alternatively, doesanyone know of another free/cheap chart tool, for asp.net which abcpdf would be able to render as a pdf, or a tool that can render google charts as pdf ?
this short answer made it work.
https://stackoverflow.com/a/13482231/744610
calling my drawchart function made the chart render and the pdf not contains everything needed.
this short answer made it work.
https://stackoverflow.com/a/13482231/744610
calling my drawchart function made the chart render and the pdf not contains everything needed.