2

this is the function i'm calling for downloading the page

printComponent(cmpName) {
let printContents = document.getElementById(cmpName).innerHTML;
let originalContents = document.body.innerHTML;

document.body.innerHTML = printContents;

window.print();


document.body.innerHTML = originalContents;}

it is working but a intermediate step comes. the project requires direct download

1 Answers1

4

You can use pdfmake

export class AppComponent {
  generatePdf(cmpName){
  const documentDefinition = { content: document.getElementById(cmpName).innerHTML 
 };
  pdfmake.createPdf(documentDefinition).open();
 }
}