【发布时间】:2018-06-27 13:59:15
【问题描述】:
我正在尝试在 html2canvas() 中使用变量“问题”。这个变量是一个对象数组。
我可以在 html2canvase() 的外部进行 console.log 它,但不能在内部。有没有办法传到里面?
这是在 app.component.ts 中
download(){
console.log("outside -> download() " + this.problems.length);//works
html2canvas(document.getElementById('graph')).then(function(canvas) {
console.log("inside -> download() " + this.problems.length);//not working
var img = canvas.toDataURL("image/png");
var doc = new jsPDF();
...............
// var dnow = Date.now();
// var d = new Date(dnow);
doc.setTextColor(0);
doc.text(5,5,'date here');//will get date in here
doc.addImage(img,'JPEG',120,20);
doc.save('testCanvas.pdf');
});
}
【问题讨论】:
标签: angular jspdf html2canvas