我在通过html2canvas将div渲染为图像时遇到问题.

function saveImages(i)

{

html2canvas($("#page"+i), {

logging:true,

onrendered: function(canvas){

var url = canvas.toDataURL();

$.post("saveImage.php", {"path": url, "index":i}, function(data){

var p = Math.round(((i+1)/totalPages)*100);

$("#progressGraphical").css("width", p+"%");

if(p>=100){p = "fertig!"}else{p += "%";}

$("#progress").html((i+1)+"/"+totalPages+" Seiten gespeichert - "+p);

if(i

});

}

});

}

$(document).ready(function(){

saveImages(0);

});

由于必须使用jquery函数完成后请求,因此我必须递归工作.

请求的php文件采用canvas.toDataUrl-Method生成的base64编码的url,对其进行解码并将其保存到名为“ page0 / 1/2 /…/ n.png”的图像文件中.

所有这些工作正常-直到超过总数约24个递归调用.如果是这种情况,那么html2canvas生成的所有图像(甚至是第24个递归调用之前的图像)都被绘制为空白.我已经看过base64编码的url-并且只有两个相等的字符串交替出现.

错误在哪里?

解决方法:

simply add css background-color:#ffffff to your table

标签:javascript,php

来源: https://codeday.me/bug/20191122/2055832.html

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐