Horje
html to pdf angular Code Example
html to pdf angular
npm install --save pdfmake
npm install html-to-pdfmake
npm install jspdf --save

ts file:
import jsPDF from 'jspdf';
import pdfMake from 'pdfmake/build/pdfmake';
import pdfFonts from 'pdfmake/build/vfs_fonts';
pdfMake.vfs = pdfFonts.pdfMake.vfs;
import htmlToPdfmake from 'html-to-pdfmake';

...
@ViewChild('pdfTable') pdfTable: ElementRef;
  
  public downloadAsPDF() {
    const doc = new jsPDF();
   
    const pdfTable = this.pdfTable.nativeElement;
   
    var html = htmlToPdfmake(pdfTable.innerHTML);
     
    const documentDefinition = { content: html };
    pdfMake.createPdf(documentDefinition).open(); 
    
    
HTML file:
<div class="container">
  <div id="pdfTable" #pdfTable>
...
</div>
  <button class="btn btn-primary" (click)="downloadAsPDF()">Export To PDF</button>
</div>




Html

Related
pavlova Code Example pavlova Code Example
acept img html Code Example acept img html Code Example
Representing the transition on image Code Example Representing the transition on image Code Example
html code example Code Example html code example Code Example
date Code Example date Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7