🌐
npm
npmjs.com › package › html2pdf.js › v › 0.9.0
html2pdf.js - npm
Install html2pdf and its dependencies using Bower with bower install --save html2pdf.js (make sure to include .js in the package name).
      » npm install html2pdf.js
    
Published   Sep 17, 2025
Version   0.9.0
Author   Erik Koopmans
🌐
GitHub
github.com › eKoopmans › html2pdf.js › issues › 398
How to setup html2pdf in Angular 11? · Issue #398 · eKoopmans/html2pdf.js
February 20, 2021 - How to setup html2pdf in Angular 11?#398 · Copy link · JuanDa237 · opened · on Feb 20, 2021 · Issue body actions · I do the following commands: npm i jspdf html2pdf npm i @types/jspdf -D · And in the angular.json i add: ... "scripts": [ ... "node_modules/jspdf/dist/jspdf.min.js" ], ...
Published   Feb 20, 2021
🌐
Stack Overflow
stackoverflow.com › questions › 68529900 › import-as-html2pdf-from-html2pdf-js
angular - import * as html2pdf from 'html2pdf.js'; - Stack Overflow
<script src="https://rawgit.com/eKoopmans/html2pdf/master/dist/html2pdf.bundle.min.js"></script> This script was already present in the index.html. I just declared the variable in the component. ... Worked for me. ... @DVN-Anakin please have a look if you find anything, I have updated the question with tsconfig.json files ... Maybe try to use the working settings of angularCompilerOptions in your tsconfig, also maybe remove lines 6, 7, 8, 9
🌐
StackBlitz
stackblitz.com › edit › angular-ivy-hwve7x
html2pdf - StackBlitz
A angular-cli project based on @angular/animations, @angular/compiler, @angular/core, @angular/common, @angular/platform-browser-dynamic, @angular/forms, @angular/platform-browser, rxjs, tslib, zone.js and @angular/router.
🌐
YouTube
youtube.com › coding diksha
Angular 12 HTML to PDF using HTML2PDF.js Library(jsPDF & HTML2Canvas Library) - YouTube
In this tutorial, I am going to teach you “How to Convert HTML Table to PDF using HTML2PDF.js in Angular 12 application”. https://codingdiksha.com/convert-ht...
Published   October 15, 2021
Views   4K
🌐
YouTube
youtube.com › watch
Export html to PDF using Angular and html2pdf.js - YouTube
Exporting HTML to PDF in Angular 2+ using html2pdf.js library.Library: https://www.npmjs.com/package/html2pdf.jsFeel free to ask us any questions in comments...
Published   June 17, 2019
🌐
Medium
medium.com › @fakharnia.2m › generating-pdfs-from-html-in-angular-with-html2pdf-js-a09c913e6e89
Generating PDFs from HTML in Angular with html2pdf.js | by Mohammad Mahdi Fakharnia | Medium
April 22, 2025 - I ultimately used the html2pdf.js package, which utilizes jsPDF. In this article, I won’t delve into the complexities of implementing such intricate scenarios. Instead, I’ll cover the essential aspects that will enable developers to effectively use this package for their own requirements. I’m using TypeScript and Angular framework here, but you can adapt the code to other JavaScript/TypeScript frameworks like React, Next.js, or Vue.js.
🌐
GitHub
github.com › Avinash-Gatsy › html2pdf-angular
GitHub - Avinash-Gatsy/html2pdf-angular: convert html to pdf using jspdf in angular 6
convert html to pdf using jspdf in angular 6. Contribute to Avinash-Gatsy/html2pdf-angular development by creating an account on GitHub.
Author   Avinash-Gatsy
Top answer
1 of 6
22

What I found worked was adding:

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>

to the index.html file (it could presumably be elsewhere).

I then used:

const elementToPrint = document.getElementById('foo'); //The html element to become a pdf
const pdf = new jsPDF('p', 'pt', 'a4');
pdf.addHTML(elementToPrint, () => {
    doc.save('web.pdf');
});

Which no longer uses html2canvas in the code.
You can then remove the following import:

import * as html2canvas from 'html2canvas';
2 of 6
9

In case someone prefer not to use cdn scripts & would like to use a more (angular) way, this worked for me in Angular 6:

Using this way will give you better support & autocomplete in the editor & will help you avoid depending on cdn scripts (if you wanna avoid them, like me)

Based on the excellent answer here & since it was hard for me to find that answer, I am re-sharing what was stated in it & helped me use jsPDF in Angular 6 (all credit goes to the original author of this answer)

You should run these cmds:

npm install jspdf --save

typings install dt~jspdf --global --save

npm install @types/jspdf --save

Add following in angular-cli.json:

"scripts": [ "../node_modules/jspdf/dist/jspdf.min.js" ]

html:

<button (click)="download()">download </button>

component ts:

import { Component, OnInit, Inject } from '@angular/core';
import * as jsPDF from 'jspdf'
@Component({
  ...
  providers: [
    { provide: 'Window',  useValue: window }
  ]
})
export class GenratePdfComponent implements OnInit {

  constructor(
    @Inject('Window') private window: Window,
    ) { }

  download() {

        var doc = new jsPDF();
        doc.text(20, 20, 'Hello world!');
        doc.text(20, 30, 'This is client-side Javascript, pumping out a PDF.');
        doc.addPage();
        doc.text(20, 20, 'Do you like that?');

        // Save the PDF
        doc.save('Test.pdf');
    }
}
Find elsewhere
🌐
YouTube
youtube.com › watch
Angular 9 Convert HTML to PDF Using html2pdf.js Library Full Project 2020 - YouTube
Buy the full source code of application here:https://procodestore.com/index.php/product/angular-9-convert-html-to-pdf-using-html2pdf-js-library-full-project-...
Published   March 10, 2020
🌐
GitHub
github.com › eKoopmans › html2pdf.js › issues › 113
Importing html2pdf ionic3/Angular4 · Issue #113 · eKoopmans/html2pdf.js
Importing html2pdf ionic3/Angular4#113 · Copy link · smart548 · opened · on May 8, 2018 · Issue body actions · Hi, I've downloaded the library through the npm install command as suggested and everything installed in the node_modules folder as expected.
🌐
ItSolutionstuff
itsolutionstuff.com › post › angular-convert-html-to-pdf-file-exampleexample.html
Angular Convert HTML to PDF File Example - ItSolutionstuff.com
October 20, 2023 - we will use pdfmake, html-to-pdfmake and jspdf package for generate pdf file from html view in angular app.
🌐
C# Corner
c-sharpcorner.com › article › html-to-pdf-using-jspdf-in-angular
HTML To PDF Using JSPDF In Angular
February 13, 2023 - In this article, you will learn about Html to Pdf using jspdf in angular.
🌐
GitHub
github.com › eKoopmans › html2pdf.js › issues › 127
problem with html2pdf, jsPDF and angular5 · Issue #127 · eKoopmans/html2pdf.js
January 7, 2018 - const pdf = new jsPDF('p', 'pt', 'letter'); html2pdf(this.document.body, pdf, function(pdfOut) { pdfOut.save('Test.pdf'); });
Published   Jun 19, 2018
🌐
Codingdiksha
codingdiksha.com › convert-html-table-to-pdf-using-html2pdf-angular
Angular html2pdf Convert HTML Table to PDF using ...
kasloy adalah situs online slot terbaik di Indonesia. Menawarkan permainan yang adil yang di dukung dengan server yang lebih stabil.
🌐
Medium
medium.com › @berkayyyulguel › angular-convert-html-to-pdf-via-jspdf-8c63c8c61ad9
Converting HTML documents to PDF using jsPDF and Angular | by Berkay Ülgüel | Medium
May 10, 2022 - Converting HTML documents to PDF using jsPDF and Angular Hey, devs! In this article, I will guide you to export pure HTML elements to PDF with the advantages of the library called jsPDF. The code in …