html2canvas保存到pdf时出现网络错误。“下载失败-网络错误”

时间:2019-08-28 17:40:08

标签: angular html2canvas

我正在研究使用html2canvas以角度将div转换为pdf的代码。它在服务器上不起作用。给出错误失败的网络错误

下面提供了我正在使用的代码。请仅通过以下代码帮助我

public captureScreen()  
  {  
    var data = document.getElementById('contentToConvert');  
    html2canvas(data).then(canvas => {  
      // Few necessary setting options  
      var imgWidth = 208;   
      var pageHeight = 295;    
      var imgHeight = canvas.height * imgWidth / canvas.width;  
      var heightLeft = imgHeight;  

      const contentDataURL = canvas.toDataURL('image/png')  
      let pdf = new jspdf('p', 'mm', 'a4'); // A4 size page of PDF  
      var position = 0;  
      pdf.addImage(contentDataURL, 'PNG', 0, position, imgWidth, imgHeight)  
      pdf.save('MYPdf.pdf'); // Generated PDF   
    });  
  }  

上述代码https://docs.python.org/3/library/functions.html#filemodes的参考链接

0 个答案:

没有答案