I am using Google visualizatio API Table and Imagechart . I want to render it as pdf . Please suggest me. Here is my code:

  • What happens when you set the VF page to render as PDF? – Mike Chale Apr 16 '13 at 11:54
  • nothing will be showing in the page. – R.Malla Apr 16 '13 at 13:08

First and foremost this is not a salesforce question.

I think that this is not possible to do.

Google API use canvas and similar techniques to draw a chart, and create his own dom elements to draw the table. There are no way to translate that rendering into a PDF in a browser by now.

  • Is there Any other way to render as Pdf. – R.Malla Apr 16 '13 at 13:46

Google has "image charts" API you could use but it's deprecated and you shouldn't really rely on it for production purposes.

You won't be able to embed "normal" charts because they rely on JavaScript to draw.

There might be other solutions available to you. Check out AppExchange or maybe decide to use something internal... For example you could set up a PHP-powered server with GD library to serve pictures, fetch them (only during PDF creation or maybe prefetch & save as attachments)? There's http://jpgraph.net/ but probably every language you're familiar with will have some library worth checking out.


To use this API make sure that you've added right "Remote Site Setting" (you might also tick disable protocol security if you suspect HTTP/HTTPs errors).

Sample email with PDF attachment containing an image:

<messaging:emailTemplate subject="test" recipientType="User" relatedToType="Account">
<messaging:plainTextEmailBody >
    Hi Salesforce StackExchange!
<messaging:attachment renderAs="pdf">
    <img src="http://chart.googleapis.com/chart?cht=p3&chd=s:Uf9a&chs=250x100&chl=January|February|March|April" />

The Remote Site I've added is http://chart.googleapis.com

  • I also try with ImageChart but Even the ImageChart also not displaying any chart in pdf. Can you provide me the sample of code. – R.Malla Apr 16 '13 at 13:22
  • @R.Malla add the chart API's domain as a Remote Site Setting, then the PNGs may load – bigassforce Apr 16 '13 at 13:23
  • I have already added these to the remote site setting.The API Domain I added is google.com/jsapi. – R.Malla Apr 16 '13 at 13:34
  • Hi Eyescream, For emails that's OK but my case is how to render google visualization api as PDF. How can I use the above code can please suggest me. I have two existing google visualization ImageCharts i want PDF for that. Thanks in advance. – R.Malla Apr 17 '13 at 8:48
  • As per Martin's answer - you can't get your existing charts exactly as they are into a PDF document! If you want to use this old images API you'll have to read its documentation and figure out how to craft an URL that'll be the image's source. developers.google.com/chart/image/docs/data_formats. You'll need to spend some more time developing it and I wouldn't advise it anyway if it's deprecated... But don't expect us to understand your data, the chart you're after and do your work for you, give you complete solution... – eyescream Apr 17 '13 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.