You need to sign in to do that
Don't have an account?
ramesh kopparapu 15
create a chart in visualforce page and want to render as pdf
Hi,
I want to create a chart in visualforce page and want to render as pdf.
I used apex:chart and along renderas pdf doesn't work for me.
I tried google charts(By converting the data into image) also, that is also not working both the cases i am getting empty pdf document.
I want to create a chart in visualforce page and want to render as pdf.
I used apex:chart and along renderas pdf doesn't work for me.
I tried google charts(By converting the data into image) also, that is also not working both the cases i am getting empty pdf document.
If you want to show chart on PDF , then you can use Google charts. As Apex:chart will not render on PDF.
Could you please post your Code here?
It will help us to identify the issue.
Did you try creating remote site for Google charts API?
Hope this helps.
The only options i can suggest is create a dashboard and get the chart image from the dashboard and use in pdf renders
Below is the sample data that i have tried, when i am converting this as a PDF
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Element', 'Density', { role: 'style' }],
['Copper', 8.94, '#b87333', ],
['Silver', 10.49, 'silver'],
['Gold', 19.30, 'gold'],
['Platinum', 21.45, 'color: #e5e4e2' ]
]);
var options = {
title: "Density of Precious Metals, in g/cm^3",
bar: {groupWidth: '95%'},
legend: 'none',
};
var chart_div = document.getElementById('chart_div');
var chart = new google.visualization.ColumnChart(chart_div);
// Wait for the chart to finish drawing before calling the getImageURI() method.
google.visualization.events.addListener(chart, 'ready', function () {
chart_div.innerHTML = '<img src="' + chart.getImageURI() + '">';
console.log(chart_div.innerHTML);
});
chart.draw(data, options);
}
</script>
<div id='chart_div'></div>
</head>
</html>
salesforce-lightning-how-to-generate-pdf-with-charts-and-images (https://csrviswa.medium.com/salesforce-lightning-how-to-generate-pdf-with-charts-and-images-f10f5dfef45e)