在Angular 6中使用多个getElementById打印多个html2canvas

时间:2018-11-30 12:13:55

标签: angular6 jspdf html2canvas

我正在使用html2canvas将html转换为pdf。但是我的元素位于具有不同ID的不同html页面上。

例如:

index.html

<html>
   <body>
      <header id="header">Header</header>
   </body>
</html>
app.component.html

<div id="content">Content</div>
app.component.ts

data = document.getElementById('content');
html2canvas(data).then(canvas => {
      contentDataURL = canvas.toDataURL('image/png')
      pdf.addImage(contentDataURL, 'PNG', 0, position, imgWidth, imgHeight)
      pdf.save('MYPdf.pdf'); 
});

但是,这仅打印“内容”数据,而不打印标题数据。我希望使用html2canvas将ID(即标题和内容)都打印在同一pdf上。         请帮助。

0 个答案:

没有答案