-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Closed
Description
Hi,
I'm trying to use jsPdf addHtml within an angular directive but It returns an error.
I'm using Version 1.1.135-git
<script type="text/javascript" src="../js/plugins/jsPDF/libs/html2canvas/dist/html2canvas.js"></script>
<script type="text/javascript" src="../js/plugins/jsPDF/dist/jspdf.debug.js"></script>
tecomaApp.directive('exportHtml', function(){
return {
restrict: 'A',
link: function($scope, elm, attr){
var pdf = new jsPDF('p', 'pt', 'letter');
var specialElementHandlers = {
'#exclude-from-print-1': function(element, renderer){
return true;
},
'#exclude-from-print-2': function(element, renderer){
return true;
}
};
$scope.$on('export-pdf', function(e, d){
var source = $(elm).get(0);
var margins = {
top: 15,
bottom: 20,
left: 15,
width: 750
};
pdf.fromHTML(source, 15, 15, {
'width': margins.with,
'margin': 1,
'pagesplit': true,
'elementHandlers': specialElementHandlers
});
pdf.save('test.pdf');
});
}
}
});
I'm getting this errir:
TypeError: pdf is undefined
var canvas = pdf.canvas; jspdf.debug.js (line 15637, col 5)
Can you tell me what is wrong with my method
Thanks
Metadata
Metadata
Assignees
Labels
No labels