如何在jspdf和angular 6中向多个页面添加页眉和页脚?

时间:2019-10-03 11:45:07

标签: angular sharepoint jspdf

代码包含具有动态高度和宽度的动态页面。因此,用页码设置页眉和页脚会出现问题。

`if (this.Results.length > 0) {
      await this.Results.forEach((element) => {
        const fai = document.getElementById(element.pageNumber); // fai
        html2canvas(fai).then(canvas => { 
          const imgWidth = 210;
          const pageHeight = 295;
          const imgHeight4 = canvas.height * imgWidth / canvas.width;
          let heightLeft4 = imgHeight4;
          const contentDataURL = canvas.toDataURL('image/png', 1.0);
          const position8 = 0;
          pdf.addPage();
          this.sharedService.showHideLoader(true);
          pdf.addImage(contentDataURL, 'PNG', 0, position8, imgWidth, imgHeight4);
          heightLeft4 -= pageHeight;
        while (heightLeft4 >= 0) {
            let position9 = heightLeft4 - imgHeight4;
            pdf.addPage();
            pdf.addImage(contentDataURL, 'PNG', 0, position9, imgWidth, imgHeight4);
            heightLeft4 -= pageHeight;
          }
        });
      });
    }`

我希望输出pdf必须具有页眉和页脚

0 个答案:

没有答案