Created
January 4, 2016 10:57
-
-
Save Alexintosh/dc309ddf319be350a435 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var doc = new $window.jsPDF("p", "mm", "a4"); | |
$timeout(function(){ | |
$window.html2canvas( $document[0].getElementsByClassName('print-pass'), { | |
onrendered: function(canvas){ | |
var imgData = canvas.toDataURL('image/png'); | |
//Page size in mm | |
var pageHeight = 295; | |
var imgWidth = 210; | |
var imgHeight = canvas.height * imgWidth / canvas.width; | |
var heightLeft = imgHeight; | |
var position = 0; | |
doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight); | |
heightLeft -= pageHeight; | |
while (heightLeft >= 0) { | |
position = heightLeft - imgHeight; | |
doc.addPage(); | |
doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight); | |
heightLeft -= pageHeight; | |
} | |
doc.autoPrint(); | |
doc.output('dataurlnewwindow'); | |
//doc.save( booking.bookingRef + '.pdf'); | |
} | |
}); | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unable to resolve $window and $timeout funtions.
Any help will be appreciated.