首页 > 解决方案 > 以角度将HTML页面导出为pdf

问题描述

导出为并导出 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
    });
}

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

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

标签: javascriptangular

解决方案


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


推荐阅读