Skip to content

Commit 00c2602

Browse files
author
Daniel Dotsenko
committed
addImage - make it work on IE8 and less
which does not have Object.keys() JS version is too old
1 parent 671626f commit 00c2602

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

jspdf.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ function jsPDF(/** String */ orientation, /** String */ unit, /** String */ form
121121
blockLength = imgData.charCodeAt(i)*256 + imgData.charCodeAt(i+1)
122122
}
123123
}
124-
125124
}
126125
// simplified (speedier) replacement for sprintf's %.2f conversion
127126
, f2 = function(number){
@@ -671,7 +670,13 @@ function jsPDF(/** String */ orientation, /** String */ unit, /** String */ form
671670
if (format.toUpperCase() !== 'JPEG') {
672671
throw new Error('addImage currently only supports format \'JPEG\', not \''+format+'\'');
673672
}
674-
var imageIndex = Object.keys(images).length;
673+
var imageIndex = Object.keys ?
674+
Object.keys(images).length :
675+
(function(o){
676+
var i = 0
677+
for (var e in o){if(o.hasOwnProperty(e)){ i++ }}
678+
return i
679+
})(images)
675680

676681
var dims = getJpegSize(imageData);
677682
var info = {

0 commit comments

Comments
 (0)