繁体   English   中英

将 HTML 页面导出到 angular 中的 pdf

[英]Export HTML page to pdf in angular

导出为和导出 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 },
    }
  }

致电 function:

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

对此的任何解决方案在此处输入图像描述

Html 打印片段图像: 在此处输入图像描述

在 google chrom 中,您可以设置要打印的视图并指定要打印的媒体类型,然后添加与打印类型相关的 css 此 css 将仅适用于打印心情使用此答案来检查如何切换到打印心情。

我对 Angular 中的 pdf 有很多经验。

其中最好的库是https://www.npmjs.com/package/jspdf

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM