I've been struggling for a few weeks on creating functionality to allow me to print my fabricjs canvas. I've tried the methods mentioned here without luck. I'm able to get to the print dialog, however, it's blank aside from the title and page info. Can anyone point me in the right direction?
I'm currently using:
// Trying to print
function printCanvas()
{
var dataUrl = document.getElementById('c').toDataURL(); //attempt to save base64 string to server using this var
var windowContent = '<!DOCTYPE html>';
windowContent += '<html>'
windowContent += '<head><title>Print canvas</title></head>';
windowContent += '<body>'
windowContent += '<img src="' + dataUrl + '">';
windowContent += '</body>';
windowContent += '</html>';
var printWin = window.open('','','width=340,height=260');
printWin.document.open();
printWin.document.write(windowContent);
printWin.document.close();
printWin.focus();
printWin.print();
printWin.close();
}
<button onclick="printCanvas()">Print</button>