I have a custom object and in the layout I have a Visualforce Page displayed. The VF utilizes <apex:chart> and JS to create graph based on field in the object. I want to create a report of the object to display a summarized view of the object's fields and to display the chart. From what I've read with the deprecating of Google Charts, it's not possible to render such charts to a PDF. I've been trying to figure if there is some way to create a static version of the image. I've noticed that the standard Printable View action on Salesforce successfully renders the embedded VF chart into a PDF, although its formatting is not great and gives more than I want to show. Is there anyway to utilize this built in action or customize it, etc.?

Here is the page for my chart for reference:

<apex:page standardController="Consumable_Analysis__c" >
// initialCost, subsqCost, and currentMethod are all taken from the object
//var declarations    
function yearCalc(m1,b1,m2,b2) {//...}
function createLinearData(m1,b1,m2,b2,length){//...} 
data.push({'name':startYear, 'data1':0,'data2':0});
years = yearCalc(subsqCost,initialCost,currentMethod,currentMethod);
<apex:chart height="500" width="750" data="data" >
      <apex:legend position="right" />
      <apex:axis type="Numeric" position="left" fields="data1"
        title="Total Cost of Method" grid="true" />
      <apex:axis type="Category" position="bottom" fields="name"
        title="Years From Purchase"/>
     <apex:lineSeries title="Future Cost Per Year" axis="left" fill="false" 
          xField="name" yField="data1" markerSize="2" smooth="2" />
     <apex:lineSeries title="Current Cost Per Year" axis="left" fill="false" 
          xField="name" yField="data2" markerSize="2"/>
  • 1
    We had to implement a heroku service that used jfree.org/jfreechart to produce our charts as an image and return them to the PDF rendered VF page. Not sure if that is needed for your solution but that is how we ended up doing it a few years ago....There may be a better option now though.
    – Eric
    Commented Dec 7, 2016 at 17:58


You must log in to answer this question.

Browse other questions tagged .