Hi,
I'm trying to use jsPdf addHtml within an angular directive but It returns an error.
<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
See #529 and pull the latest merge. That might fix your problem.
Thanks for replaying. I tried this merge in jsPdf.debug.js but now I'm getting this error:
Error: Mismatched anonymous define() module: function (){return Mt}
http://requirejs.org/docs/errors.html#mismatch
var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);
Thanks for your help
stupid library ... all the people having the same issues, and no body know what is happening... 卢卢
mine works only with simple materliaze grid layout with text
it doesn't work with images (complete black pdf).
it also shows a border i don't want and the text is a bit blurry as jsPDF just takes a screenshot (with html2canvas)
pdfMake is an alternative but seems alot of work styling the layout of those reports manually
Hi everbody, look at #600, it may fix your issues too.
Most helpful comment
stupid library ... all the people having the same issues, and no body know what is happening... 卢卢