I have this function
$scope.testepdf = function () {
var doc = new jsPDF();
doc.setFontSize(12);
doc.text(10, 10, $scope.cons_a.razao)
doc.text(10, 15, $scope.cons_a.endereco + ',' + $scope.cons_a.nr + ' - ' + $scope.cons_a.cidade + '/' + $scope.cons_a.uf)
doc.text(10, 20, $scope.cons_a.fone + ' - ' + $scope.cons_a.email)
doc.setLineWidth(0.2);
doc.line(10, 23, 160, 23);
//medicamentos
var res = doc.autoTableHtmlToJson(document.getElementById("basic-table"));
doc.autoTable(res.columns, res.data, { margin: { top: 80, left: 10 } });
var header = function (data) {
doc.setFontSize(18);
doc.setTextColor(40);
doc.setFontStyle('normal');
//doc.addImage(headerImgData, 'JPEG', data.settings.margin.left, 20, 50, 50);
doc.text("Testing Report", data.settings.margin.left, 50);
};
When trying to generate pdf, error occurs:
angular_common.min.js:1 TypeError: doc.autoTableHtmlToJson is not a function
at Scope.$scope.testepdf (consultaController.js:477)
Looking at the documentation, I believe I imported it correctly:
<script src="https://unpkg.com/jspdf@latest/dist/jspdf.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/2.3.2/jspdf.plugin.autotable.js"></script>
The problem only happens when I try to use autotable because I need to show an array of objects.
What could be happening?