How to print a canvas element?

后端 未结 2 1082
囚心锁ツ
囚心锁ツ 2021-01-19 05:12

I have a canvas element on my page. I draw an image over it and some data that the user entered. On a press of a button I want to send the canvas to printer, to print it on

2条回答
  •  执笔经年
    2021-01-19 05:39

    This will convert the canvas to a .png image URL and open it in a new browser window

    The Print Dialog is triggered to let the user print the page.

    function print_voucher(){
        var win=window.open();
        win.document.write("
    "); win.print(); win.location.reload(); }

    Here is example code:

    
    
    
    
    
    
    
        

提交回复
热议问题