【问题标题】:Black box instead of the image in canvas黑框而不是画布中的图像
【发布时间】:2020-09-22 17:27:27
【问题描述】:

也许有人可以帮助我使用 html2canvas 保存带有图像的 pdf 文件 这是我的代码

 html2canvas(document.images, {
        onrendered: function(canvas){

            let ctx = canvas.getContext("2d");

            ctx.globalAlpha = 0.05;
            ctx.fillStyle = "#fff";

            let img = canvas.toDataURL('image/jpeg', 1.0);
            let doc = new jsPDF();
            doc.addImage(img, 'JPEG', 0, 0);
            doc.save('Wishes.pdf')
        },
    })

【问题讨论】:

    标签: javascript html pdf canvas html2canvas


    【解决方案1】:

    可能是因为您在加载之前绘制了图像

    我找到了这个例子:https://stackoverflow.com/a/24997626/9231356

    希望它对你有用!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-03
      • 2019-04-12
      • 2018-11-25
      • 2019-05-29
      • 1970-01-01
      • 1970-01-01
      • 2019-11-27
      相关资源
      最近更新 更多