【问题标题】:HTML2Canvas - get created canvas image URI [duplicate]HTML2Canvas - 获取创建的画布图像 URI [重复]
【发布时间】:2015-05-17 22:04:22
【问题描述】:

我有一个好主意,可以结合 html2canvas 和 jspdf 来生成 PDF-s,尽管在 jspdf 中生成带有图像的 PDF 需要图像 URI。我在这方面真的很陌生,所以我认为也许也可以创建画布 uri?

我使用函数创建画布:

function makeCanvas(){
var $printSection = makeImage(); //just a function to group up elements for canvas
html2canvas($printSection, {
    onrendered: function(canvas){
        console.log(canvas); //get URI???
    }
});
}

我现在想做的是获取已创建画布的 URI。有没有可能,如果有,那怎么办?

【问题讨论】:

    标签: javascript canvas html2canvas jspdf


    【解决方案1】:

    您可以使用 .toDataURL() 来生成 data-uri:

    canvas.toDataURL()
    

    【讨论】:

      猜你喜欢
      • 2021-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-04
      • 2023-03-05
      • 2013-05-14
      • 1970-01-01
      相关资源
      最近更新 更多