I am currently working on an Angular JS application that utilizes JSPDF for generating PDFs.
While the PDF generation functionality works perfectly fine on Chrome, Firefox, and Safari, it encounters issues on Internet Explorer (IE). The specific error message I receive in IE is:
SCRIPT438: Object doesn't support property or method 'trimLeft'
jspdf.plugin.from_html.js, line 71 character 4
Here is a snippet of the JavaScript code responsible for generating the PDF:
function mainControl($scope) {
$scope.showtooltip = false;
$scope.value = 'Generate PDF';
$scope.hideTooltip = function() {
$scope.showtooltip = false;
}
$scope.toggleTooltip = function(e) {
e.stopPropagation();
$scope.value = 'HERE';
$scope.showtooltip = !$scope.showtooltip;
}
}
function printPDF() {
var doc = new jsPDF();
var elementHandler = {
'#oi' : function(element, renderer) {
return true;
}
};
var source = window.document.getElementsByTagName("body")[0];
doc.fromHTML($('#content').get(0), 10, 15, {
'width' : 190
});
doc.setFont("helvetica");
doc.setFontType("normal");
doc.setTextColor(198, 0, 24);
doc.setFontSize(10);
doc.text(10, 10, 'xxxx');
doc.output("dataurlnewwindow")
}
var Show = {
getFromPDF : function() {
$('#btn-pdf').click(function() {
printPDF();
});
}
}
$(function() {
Show.getFromPDF();
});