🌐
GitHub
github.com › alpitg › angular-jspdf
GitHub - alpitg/angular-jspdf: Angular 7 + jspdf + pdf download sample
Angular 7 + jspdf + pdf download sample. Contribute to alpitg/angular-jspdf development by creating an account on GitHub.
Author   alpitg
🌐
npm
npmjs.com › package › jspdf
jspdf - npm
In Angular projects, externals can be defined using custom webpack builders. In React (create-react-app) projects, externals can be defined by either using react-app-rewired or ejecting. jsPDF can be imported just like any other 3rd party library.
      » npm install jspdf
    
Published   Nov 19, 2025
Version   3.0.4
🌐
GitHub
github.com › kumargandhi › angular-jspdf-example
GitHub - kumargandhi/angular-jspdf-example: Export PDF file using JSPDF library in Angular project.
Export PDF file using JSPDF library in Angular project. - kumargandhi/angular-jspdf-example
Author   kumargandhi
🌐
GitHub
github.com › parallax › jsPDF › issues › 2605
How can we use jsPDF in a web worker from Angular 8 app? · Issue #2605 · parallax/jsPDF
There is any way to use web workers for parallelism when generating multiple PDF pages in separate threads(in web workers) in an Angular applications ? Because when we try we received an error like 'Uncaught ReferenceError: window is not defined' ! Is this because of the limitation of web workers when using DOM elements? It look like with simple JavaScript jsPDF can be used in web worker : https://github.com/jstarcher/webworker_jspdf_example/tree/master/js How can we do the same in Angular with TypeScript ?
Published   Oct 23, 2019
Author   sorryb
🌐
jsPDF
artskydj.github.io › jsPDF › docs › index.html
jsPDF - GitHub Pages
The fontconverter will create a ... code for jsPDF. You just have to add this generated js-File to your project. You are then ready to go to use setFont-method in your code and write your UTF-8 encoded text. If you are using Webpack (including managed cli tools like angular-cli or ...
🌐
GitHub
github.com › JonatanPe › jsPDF-AutoTable
GitHub - JonatanPe/jsPDF-AutoTable
Declare jsPDF as a global variable declare var jsPDF: any;, and use as normal in any component · // angular-cli.json "scripts": [ "../node_modules/jspdf/dist/jspdf.min.js", "../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js" ],
Starred by 17 users
Forked by 4 users
Languages   TypeScript 81.5% | JavaScript 18.5%
Top answer
1 of 5
84

I have done it, after doing lot of R&D , their are few steps to follow as below : Install :

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');
    }
}
2 of 5
11

Old question but this is an alternative solution that I got up and running in my angular app. I ended up modifying this jsPDF solution to work without using the ionic/cordova CLI.

npm install jspdf --save
npm install @types/jspdf --save
npm install html2canvas --save
npm install @types/html2canvas --save

Add an id to whichever div contains the content you want to generate the PDF

<div id="html2Pdf">your content here</div>

Import the libraries

import * as jsPDF from 'jspdf';
import * as html2canvas from 'html2canvas';

Add the method for generating the PDF

generatePdf() {
    const div = document.getElementById("html2Pdf");
    const options = {background: "white", height: div.clientHeight, width: div.clientWidth};

    html2canvas(div, options).then((canvas) => {
        //Initialize JSPDF
        let doc = new jsPDF("p", "mm", "a4");
        //Converting canvas to Image
        let imgData = canvas.toDataURL("image/PNG");
        //Add image Canvas to PDF
        doc.addImage(imgData, 'PNG', 20, 20);

        let pdfOutput = doc.output();
        // using ArrayBuffer will allow you to put image inside PDF
        let buffer = new ArrayBuffer(pdfOutput.length);
        let array = new Uint8Array(buffer);
        for (let i = 0; i < pdfOutput.length; i++) {
            array[i] = pdfOutput.charCodeAt(i);
        }

        //Name of pdf
        const fileName = "example.pdf";

        // Make file
        doc.save(fileName);

    });
}

I found this solution worked well for my web app and was beneficial as I have control over when I want to generate the PDF (after receiving data asynchronously). As well, I didn't need install any libraries globally.

🌐
GitHub
github.com › alpitg › angular-jspdf › blob › master › README.md
angular-jspdf/README.md at master · alpitg/angular-jspdf
Angular 7 + jspdf + pdf download sample. Contribute to alpitg/angular-jspdf development by creating an account on GitHub.
Author   alpitg
Find elsewhere
🌐
GitHub
github.com › topics › angular-pdf-js
angular-pdf-js · GitHub Topics · GitHub
A very simple PDF viewer implementation in Angular 11 based on the PDFjs library from Mozilla. Its a great place to start for anybody who is looking to build on top of the most basic features like Canvas layer + Text layer rendering.
🌐
GitHub
github.com › parallax › jsPDF › issues › 2892
I cannot use jsPDF with Angular 10 · Issue #2892 · parallax/jsPDF
July 24, 2020 - I was trying to print my page using jspdf library version 2.1.0 with Angular version 10. I've also added a question in stackoverflow and here is the link https://stackoverflow.com/questions/63667889/i-cannot-use-jspdf-with-angular-10 Rep...
Published   Aug 31, 2020
🌐
GitHub
github.com › anik123 › Jspdf-with-Angularjs
GitHub - anik123/Jspdf-with-Angularjs
Contribute to anik123/Jspdf-with-Angularjs development by creating an account on GitHub.
Author   anik123
🌐
GitHub
gist.github.com › desmondcain › 39462bc23c7c25e11cda0fa0eb79045d
jsPDF Angular 1.x Content Formatting Service · GitHub
jsPDF Angular 1.x Content Formatting Service. GitHub Gist: instantly share code, notes, and snippets.
🌐
GitHub
github.com › sutin1234 › angular-pdf
GitHub - sutin1234/angular-pdf: make angular with jsPdf
make angular with jsPdf. Contribute to sutin1234/angular-pdf development by creating an account on GitHub.
Author   sutin1234
🌐
GitHub
github.com › parallax › jsPDF
GitHub - parallax/jsPDF: Client-side JavaScript PDF generation for everyone.
In Angular projects, externals can be defined using custom webpack builders. In React (create-react-app) projects, externals can be defined by either using react-app-rewired or ejecting. jsPDF can be imported just like any other 3rd party library.
Starred by 30.9K users
Forked by 4.8K users
Languages   JavaScript 96.4% | TypeScript 2.4% | HTML 1.2%
🌐
GitHub
github.com › sayanee › angularjs-pdf
GitHub - sayanee/angularjs-pdf: :page_facing_up: An AngularJS directive <ng-pdf> to display PDF files with PDFJS
:page_facing_up: An AngularJS directive to display PDF files with PDFJS - sayanee/angularjs-pdf
Starred by 492 users
Forked by 246 users
Languages   JavaScript
🌐
GitHub
github.com › topics › jspdf
jspdf · GitHub Topics · GitHub
PDF template created to generate invoices based on props object. Using jsPDF library.
🌐
Githubhelp
githubhelp.com › alpitg › angular-jspdf
The angular-jspdf from alpitg - GithubHelp
angular-jspdf,alpitg | angular 7 + jspdf + pdf download sample from githubhelp.