0

I'm using jsPDF and I've added its jspdf.min.js file on the page.

How can I use it from within a typescript class? jsPDF is unknown it complains:

  btnPrintReportClick() {
        var pdf = new jsPDF();
        pdf.fromHTML($('.container').html(), 15, 15, { 'width': 170 });
        pdf.save('file_name.pdf');
    }
1
  • You'll have to give us more information for us to help you. In general, TypeScript requires that you have a definitions file for any JavaScript code you're including, since TypeScript overlays a type system on JavaScript. More: typescriptlang.org/docs/handbook/declaration-files/… Commented Mar 20, 2017 at 17:00

1 Answer 1

2

You'll need to use the definition file for it.

From your question I assume that you're loading jspdf simply by placing a script tag in your page, and in that case just add this triple-slash-directive to your typescript file:

/// <reference path="PATH/TO/jspdf.d.ts />
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.