将HTML页面导出为有角

时间:2019-11-21 09:56:31

标签: javascript angular

以as格式导出​​和导出pdf,导出的pdf文档不正确,未插入标有红色的标记以供参考,另加图像。 下面是我的配置:

  exportAsConfig: ExportAsConfig = {
    type: 'pdf', // the type you want to download
    //elementId: 'balance-sheet-preview', // the id of html/table element
    elementId: 'contentToConvert', // the id of html/table element
    options: { // html-docx-js document options
      margins: {
        top: '20',
        bottom: '5'
      },
      orientation: 'landscape',
      filename: 'engagement.pdf',
      image: { type: 'jpeg', quality: 1 },
    }
  }

调用函数:

export(){
this.exportAsService.save(this.exportAsConfig, 'engagementLetter').subscribe(() => {
      // save started
    });
}

对此的任何解决方案enter image description here

HTML打印段图像: enter image description here

2 个答案:

答案 0 :(得分:2)

在Google chrom中,您可以将视图设置为打印并指定要打印的介质类型,然后添加与打印类型相关的CSS,此CSS仅在打印环境中适用 使用此answer检查如何切换到打印心情。

答案 1 :(得分:1)

我在Angular中使用pdf有很多经验。

其中所有人中最好的图书馆是https://www.npmjs.com/package/jspdf

示例:https://rawgit.com/MrRio/jsPDF/master/

文档:https://rawgit.com/MrRio/jsPDF/master/docs/