2

I'm a beginner with anychart library. I'm trying to get the chart as image and insert it inside a pdf. I know that anychart has the following function to download the chart as pdf.

chart.saveAsPdf({"filename": id_container});

However I need to customize my pdf with jsPDF.

The method

chart.saveAsJpg({"filename": id_container});

automatically download the image. I'm using the 8.7.1 version.

Penny Liu
  • 15,447
  • 5
  • 79
  • 98
Paul
  • 223
  • 2
  • 14

1 Answers1

1

You can get the char image as base64 encoded string without downloading it. Check the getJpgBase64String() function.

AnyChart Support
  • 3,770
  • 1
  • 10
  • 16
  • How can I call it with width and height? – Paul Jun 10 '20 at 09:43
  • 1
    The 3rd and 4th function arguments are width and height. You can apply them like this: ``` chart.getJpgBase64String( function (response) { var base64String = document.getElementById('getJpgBase64String'); base64String.innerHTML = response; }, function(err) { console.log(err); }, 600, 600); ``` The full description you can find in the API reference - https://api.anychart.com/anychart.core.Chart#getJpgBase64String – AnyChart Support Jun 11 '20 at 03:32