Option to export PDF to dataUri string instead of downloading
It would be nice to have an option to export chart (as PDF) to datauri string instead of file.
This can be done now indirectly, by obtaining chart's underlying svg, calling svg2pdf and finally using jsPDF doc.output('datauristring')
[which returns the base64 dataUri] instead of downloading file.
Maybe as an option in 'exporting' object?
Or by exposing new method, i.e. Highcharts.exportToUri() ?
Or maybe there's some simpler way that I am not aware of?
Thank you for your request! By extension, this applies to PNG and JPEG exports in addition to PDF. You can override the Highcharts.downloadURL function to capture the dataURI. See http://jsfiddle.net/highcharts/9my975x4/.
We looked into this, hoping that we could add this through simple refactoring. Issues arise, however, with browsers (especially IE) that use Blob instead of dataURIs for downloads. While it is possible to convert from Blobs to dataURIs, implementing this would increase the size of Highcharts.
For now, let's leave this idea open to further votes and see if it is something other users require.
Slobodan Babić commented
Thank you. It's a nice workaround.
Seems to me that It would be more elegant if there was a separate method for capturing dataURI (which could also handle SVG export to dataURI), so I hope review will be positive.
Have a nice day.