I needed to return to this subject this week and Googling revealed some potentially misleading fairly complicated solutions. There are multiple posts on the subject here e.g. Image Charts in Visualforce / PDF but many are rather dated.

So what is a good approach in early 2023?

1 Answer 1


What worked for me...

Using external sites that generate images of charts based on URL parameters remains IMHO the simplest approach. Even the nominally deprecated Google Image Charts is still running. But I used imagecharts that is now free if you don't mind a watermark on each image; that watermark can be removed for a small monthly payment. It has good documentation and examples and you can try out examples interactively; it supports Chart.js charts that you may have used before. I have no affiliation with imagecharts; just found their offering easy to use.

The gotchas for me in getting this working were:

  • You must have a remote site setup in the org as otherwise the PDF generator can't access external URLs; don't be misled that you need to pull the image into your Salesforce org for the PDF generator to be able to access it
  • You must use <apex:image value=... rather than <image src=...; don't know why
  • I recommend that the image be generated at say double the size that it will be presented in the page (so scale up font sizes to match) and then scaled down using e.g. style="width: 50%" in the page; this keeps pixelation at bay if the PDF is printed or scaled up on someone's screen

A few years ago there was a pilot to offer a better PDF generator that might have helped (renderAs="advanced_pdf") but that never became GA - see Status of renderAs advanced_pdf.

I did take a look at PDF Generator API's HTML to PDF and got it working quite quickly from Apex. If I was building the output from scratch with absolute URLs everywhere and no JavaScript, I would consider using it as it supports CSS3 and will render SVG.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .