matchifang
matchifang

Reputation: 5450

How to import jsPDF v2 in Angular 7

I'm using jsPDF in Angular 7 project. I was on jsPDF v1.3.5 and used import * as jsPDF from 'jspdf'; to import.

Now I upgraded to v2.0.0 and after the upgrade, I tried these imports with the respective errors

const { jsPDF } = require("jspdf"); //Cannot find name 'jsPDF'.
import { jsPDF } from 'jspdf';     // Error:Property 'setFontType' does not exist on type 'jsPDF

Upvotes: 0

Views: 351

Answers (1)

Benzara Tahar
Benzara Tahar

Reputation: 2217

you should use this to import jsPDF

import { jsPDF } from 'jspdf'; 

if you check the change log on github, you will see that setFontType was removed from version 2

  • Removed APIs that were previously marked as deprecated. Namely: addHTML, fromHTML, html2pdf, addSvg, addButton, addTextField, addChoiceField, cellInitialize, setFontStyle, setFontType, clip_fixed.

Upvotes: 1

Related Questions