Answer the question
In order to leave comments, you need to log in
How to download an image in base64?
In react I generate a table that can be downloaded. Those. I render the layout, then using the html2canvas.js plugin I convert the layout into a canvas element, and download the canvas element using canvas2image.js
html2canvas(ReactDOM.findDOMNode(this.refs.scheduleTable), {
onrendered: function (canvas) {
//Получаю изображение в base64
var dataURL = canvas.toDataURL('image/png');
// Convert and download as image
Canvas2Image.saveAsPNG(canvas);
}
});
TypeError: this.setState is not a functionoutside writes undefined
Canvas2Image.saveAsPNG(canvas);
saves the picture without extension, although this is the easiest way to save, it would be possible to specify the format.Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question