function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
manjeera bhmanjeera bh 

how to display SVG graph in pdf

how to save svg graph as pdf in visualforce page
sfdc550sfdc550
If you just keep renderAs=" true" in below code you will get empty in SVG code. Check it i am also giving limitations of svg also below
 
<apex:page controller="CharVF1Controller" sidebar="false">
 
<apex:chart height="400" width="700" data="{!ChartData}" rendered="true" id="chart1" name="mychart">
 
    <apex:axis type="Category" position="bottom" fields="Name"
        title="Opportunities" grid="true"/>
    <apex:axis type="Numeric" position="right" fields="Amount"
        title="Opportunity Amounts"/>
    <apex:axis type="Category" position="left" fields="StageName"
        title="Opportunity Stage"/>
 
    <apex:barSeries title="Monthly Sales" orientation="vertical" axis="right"
        xField="Name" yField="Amount" id="bar1">
        <apex:chartTips height="20" width="120"/>
    </apex:barSeries>
 
    <apex:lineSeries title="Closed-Won"
         axis="left" xField="Name" yField="Amount"
         markerType="circle" markerSize="4" markerFill="#00FF00"/>
 
</apex:chart>
</apex:page>


 
public class CharVF1Controller {
public List<Opportunity> getChartData() {      
 
        List<Opportunity> Opp = [select name, amount, stageName from opportunity where amount!=null AND stageName!=null limit 10];         
 
        return Opp;
 
    }
}





Below are some known limitations for this pilot feature:
Visualforce charts will only render in browsers which support scalable vector graphics (SVG). For more information, see WC3 SVG Working Group.
Visualforce charting uses JavaScript to draw the charts. These charts won't display in pages rendered as PDFs.
Email clients do not generally support JavaScript execution in messages. Don't use Visualforce charting in email messages or email templates.
Visualforce charting sends errors and messages to the JavaScript console. You'll want to keep a JavaScript debugging tool, such as Firebug, active during development.



If this answers you question, please mark it as "Best Answer" so it will help other community members too.
 
manjeera bhmanjeera bh
Hi ,

Thanks for posting your answer.
I have developed barchart using SVG in visualforce page. SVG barchart is not shown in pdf  when using  renderAs pdf. Could you please help me on this.
Is there any other workaround to display SVG chart in pdf?