Sử dụng PNGStream để lưu canvas HTML5 vào tệp.
var f = require('fs') , out = f.createWriteStream(__dirname + '/text.png') , stream = canvas.pngStream(); stream.on('data', function(chunk){ out.write(chunk); }); stream.on('end', function(){ console.log(‘PNG Saved successfully!’); });