npm i html2pdf.js
HTML:
... <!--HTML tabel-->
<button (click)="download()">Download PDF</button>
.ts file:
import * as html2pdf from 'html2pdf.js'
...
download(){
var element = document.getElementById('table');
var opt = {
margin: 1,
filename: 'output.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2 },
jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }
};
// New Promise-based usage:
html2pdf().from(element).set(opt).save();
}
in the tsconfig.json file add this line:
"noImplicitAny": false,