Home > Back-end >  HTML to PDF using jspdf in ionic
HTML to PDF using jspdf in ionic

Time:07-23

I want to convert html to pdf using jspdf but i want to generate the pdf without showing the html content to users. The technology im using is ionic. Please help on this issue

CodePudding user response:

  public downloadPDF() {
    const doc = new jsPDF();

    const specialElementHandlers = {
      '#editor': function (element, renderer) {
        return true;
      }
    };

    const content = this.content.nativeElement;

    doc.fromHTML(content.innerHTML, 15, 15, {
      width: 190,
      'elementHandlers': specialElementHandlers
    });

    doc.save('test.pdf');
  }

Example: https://stackblitz.com/edit/angular-html-to-pdf-example

  • Related