簡體   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