简体   繁体   English

将 HTML 页面导出到 angular 中的 pdf

[英]Export HTML page to pdf in angular

export-as and exporting pdf, exported pdf document is not proper it is not streching fully red mark inserted for reference,attached image.导出为和导出 pdf,导出的 pdf 文档不正确,它没有拉伸完全插入的红色标记以供参考,附图。 Below is my config:下面是我的配置:

  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 },
    }
  }

call in function:致电 function:

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

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

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

in google chrom you can set the view to print and specify media type to print then add css related to print type this css will applied only in printing mood use this answer to check how to switch to print mood.在 google chrom 中,您可以设置要打印的视图并指定要打印的媒体类型,然后添加与打印类型相关的 css 此 css 将仅适用于打印心情使用此答案来检查如何切换到打印心情。

I have lot of experience with pdf in Angular.我对 Angular 中的 pdf 有很多经验。

Among all of them best library is https://www.npmjs.com/package/jspdf其中最好的库是https://www.npmjs.com/package/jspdf

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

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

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

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