weixin_39915700
weixin_39915700
2021-01-11 21:46

how to get toDataURL of generated qr

I want to use the generated QR code other places in my project. Is it possible to get the image from the canvas using toDataURL? I know generally how to use toDataURL, but the problem is the canvas generated in your script has no id so I don't know how to reference it...

该提问来源于开源项目:jeromeetienne/jquery-qrcode

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • weixin_39915700 weixin_39915700 4月前

    Let me add a comment. I read previously that others were asking if you could write the qr code directly into an existing canvas. If that is possible it will fix my issue. I am basically trying to generate a qr code and place it into another canvas. the toDataURL is being used as an interim step to get an image.

    点赞 评论 复制链接分享
  • weixin_39887577 weixin_39887577 4月前

    Note in IE8 toDataURL() is not working

    点赞 评论 复制链接分享
  • weixin_39827315 weixin_39827315 4月前

    I would also like to get this working

    点赞 评论 复制链接分享
  • weixin_39632379 weixin_39632379 4月前

    can be done like this

    var dataURL = $('canvas')[0].toDataURL("image/png"); console.log(dataURL);

    window.open().document.write('<img src="' + dataURL + '" />');

    点赞 评论 复制链接分享

相关推荐