Best practices to saving HTML5 Canvas as an image
Posted: Wed Mar 07, 2018 1:03 am
So I'm trying to implement a link/button of sorts such that a client can click the button, (possibly select folder location as well) and download a TeeChart in the highest quality possible. I'm aware right-click on the canvas into Save Image As works as a feature in some browsers, however I'm looking if there is clickable alternative that will be more universal.
I've tried using
which displays the image fine using the <img id = 'test'> tag as shown in the demo example but I'm lost to where to go from here in terms of programatically downloading this image, I don't actually want to display the image just download it.
I've tried some common non-TeeChart methods such as:
alongside the download attribute to download as Base64 and some other methods, however I'm not very well experienced in this area and was wondering if there was a 'universal' method, TeeChart supported or not. Also some suggestions online are simply outdated. With some research, apparently in Base64 form (as my TeeCharts can start to get quite large) our charts produces too many characters for certain browsers to accept using some methods. Working examples only tests very small files.
Thanks in advance,
I've tried using
Code: Select all
Chart1.toImage('test', 'png')(
I've tried some common non-TeeChart methods such as:
Code: Select all
href = "document.getElementById('Canvas1').toDataURL();"
Thanks in advance,