admin管理员组

文章数量:1428481

export-as and exporting pdf, exported pdf document is not proper it is not streching fully red mark inserted for reference,attached image . 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:

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

Any solution for this

Html print snippet image:

export-as and exporting pdf, exported pdf document is not proper it is not streching fully red mark inserted for reference,attached image . 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:

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

Any solution for this

Html print snippet image:

Share Improve this question edited Nov 21, 2019 at 10:20 Sudhir asked Nov 21, 2019 at 9:56 SudhirSudhir 5791 gold badge11 silver badges29 bronze badges 3
  • 1 Could you add a small snippet of HTML that allows us to recreate this issue? – Titulum Commented Nov 21, 2019 at 10:00
  • Added html snippet – Sudhir Commented Nov 21, 2019 at 10:21
  • @Titulum any other libraries to export as pdf – Sudhir Commented Nov 21, 2019 at 10:28
Add a ment  | 

2 Answers 2

Reset to default 2

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 .

I have lot of experience with pdf in Angular.

Among all of them best library is https://www.npmjs./package/jspdf

Example : https://rawgit./MrRio/jsPDF/master/

Docs : https://rawgit./MrRio/jsPDF/master/docs/

本文标签: javascriptExport HTML page to pdf in angularStack Overflow