0

After my jsPDF is working now, I have the same problem with autoTable.

my header.php:

<head>
.....
</head>
<header>
.....
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.0.0/jspdf.umd.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.6/jspdf.plugin.autotable.min.js"></script>
</header>

I require the header.php in other.php and want to use jsPDF in this file:

require "header.php";

<body>
....
</body>

<script>
    window.jsPDF = window.jspdf.jsPDF;
    function createInvoice(final){
      const doc = new jsPDF();
      console.log(window.autotable);

      doc.text("Hello world!", 10, 10);
      doc.autoTable({
        head: [['Name', 'Email', 'Country']],
        body: [
          ['David', 'david@example.com', 'Sweden'],
          ['Castille', 'castille@example.com', 'Spain']
        ]
      });
      doc.save("a4.pdf");
    }
</script>

I tried different src, download it, but every time I am getting the following error :

doc.autoTable is not a function

Can someone help me? Thank you in advance

vDrews
  • 155
  • 5
  • 14
  • Does this answer your question? [jsPDF AutoTable - autoTable is not a function](https://stackoverflow.com/questions/44726278/jspdf-autotable-autotable-is-not-a-function) – manqlele Aug 21 '20 at 11:09
  • No, because it is with Angular and i'm not working with Angular. It's plane HTML/PHP/CSS/JS And I must work with the script tags oder Download it in my Project. But this doesn't work – vDrews Aug 21 '20 at 11:12

1 Answers1

0

it seems that jsPDF-autoTable 3.5.6 is not compatible with jsPDF version 2.0.

There is already an issue opened on github issue tracker.

deelde
  • 1,540
  • 13
  • 23