Skip to content

Commit 4c69493

Browse files
committed
Ensuring the PNG support dont break the library initialization under older browsers
1 parent 119a246 commit 4c69493

File tree

7 files changed

+43
-31
lines changed

7 files changed

+43
-31
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jspdf",
3-
"version": "1.0.118",
3+
"version": "1.0.119",
44
"homepage": "https://github.com/mrrio/jspdf",
55
"description": "PDF Document creation from JavaScript",
66
"main": "dist/jspdf.min.js",

dist/jspdf.debug.js

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @preserve
22
* jsPDF - PDF Document creation from JavaScript
3-
* Version 1.0.118-git Built on 2014-04-28T19:38
4-
* CommitID ce42cbafba
3+
* Version 1.0.119-git Built on 2014-04-29T03:48
4+
* CommitID 119a246e55
55
*
66
* Copyright (c) 2010-2014 James Hall, https://github.com/MrRio/jsPDF
77
* 2010 Aaron Spike, https://github.com/acspike
@@ -556,7 +556,7 @@ var jsPDF = (function(global) {
556556
bch = ch >> 8; // divide by 256
557557
if (bch >> 8) {
558558
/* something left after dividing by 256 second time */
559-
throw new Error("Character at position " + i.toString(10) + " of string '"
559+
throw new Error("Character at position " + i + " of string '"
560560
+ text + "' exceeds 16bits. Cannot be encoded into UCS-2 BE");
561561
}
562562
newtext.push(bch);
@@ -624,10 +624,10 @@ var jsPDF = (function(global) {
624624
out(drawColor);
625625
// resurrecting non-default line caps, joins
626626
if (lineCapID !== 0) {
627-
out(lineCapID.toString(10) + ' J');
627+
out(lineCapID + ' J');
628628
}
629629
if (lineJoinID !== 0) {
630-
out(lineJoinID.toString(10) + ' j');
630+
out(lineJoinID + ' j');
631631
}
632632
events.publish('addPage', { pageNumber : page });
633633
},
@@ -1576,7 +1576,7 @@ var jsPDF = (function(global) {
15761576
throw new Error("Line cap style of '" + style + "' is not recognized. See or extend .CapJoinStyles property for valid styles");
15771577
}
15781578
lineCapID = id;
1579-
out(id.toString(10) + ' J');
1579+
out(id + ' J');
15801580

15811581
return this;
15821582
};
@@ -1597,7 +1597,7 @@ var jsPDF = (function(global) {
15971597
throw new Error("Line join style of '" + style + "' is not recognized. See or extend .CapJoinStyles property for valid styles");
15981598
}
15991599
lineJoinID = id;
1600-
out(id.toString(10) + ' j');
1600+
out(id + ' j');
16011601

16021602
return this;
16031603
};
@@ -1693,7 +1693,7 @@ var jsPDF = (function(global) {
16931693
* pdfdoc.mymethod() // <- !!!!!!
16941694
*/
16951695
jsPDF.API = {events:[]};
1696-
jsPDF.version = "1.0.118-debug 2014-04-28T19:38:diegocr";
1696+
jsPDF.version = "1.0.119-debug 2014-04-29T03:48:diegocr";
16971697

16981698
if (typeof define === 'function') {
16991699
define(function() {
@@ -1703,7 +1703,7 @@ var jsPDF = (function(global) {
17031703
global.jsPDF = jsPDF;
17041704
}
17051705
return jsPDF;
1706-
}(self));
1706+
}(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this));
17071707
/**
17081708
* jsPDF addHTML PlugIn
17091709
* Copyright (c) 2014 Diego Casorran
@@ -7552,7 +7552,7 @@ var Deflater = (function(obj) {
75527552
*/
75537553

75547554

7555-
(function() {
7555+
(function(global) {
75567556
var PNG;
75577557

75587558
PNG = (function() {
@@ -7895,9 +7895,12 @@ var Deflater = (function(obj) {
78957895
return ret;
78967896
};
78977897

7898-
scratchCanvas = document.createElement('canvas');
7899-
7900-
scratchCtx = scratchCanvas.getContext('2d');
7898+
try {
7899+
scratchCanvas = global.document.createElement('canvas');
7900+
scratchCtx = scratchCanvas.getContext('2d');
7901+
} catch(e) {
7902+
return -1;
7903+
}
79017904

79027905
makeImage = function(imageData) {
79037906
var img;
@@ -7991,9 +7994,9 @@ var Deflater = (function(obj) {
79917994

79927995
})();
79937996

7994-
window.PNG = PNG;
7997+
global.PNG = PNG;
79957998

7996-
}).call(this);
7999+
})(typeof window !== "undefined" && window || this);
79978000
/*
79988001
* Extracted from pdf.js
79998002
* https://github.com/andreasgal/pdf.js
@@ -8118,6 +8121,9 @@ var DecodeStream = (function() {
81188121
})();
81198122

81208123
var FlateStream = (function() {
8124+
if (typeof Uint32Array === 'undefined') {
8125+
return undefined;
8126+
}
81218127
var codeLenCodeMap = new Uint32Array([
81228128
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
81238129
]);
@@ -8645,4 +8651,4 @@ var FlateStream = (function() {
86458651
};
86468652
}
86478653

8648-
})(this);
8654+
})(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this);

dist/jspdf.min.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jspdf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1703,4 +1703,4 @@ var jsPDF = (function(global) {
17031703
global.jsPDF = jsPDF;
17041704
}
17051705
return jsPDF;
1706-
}(self));
1706+
}(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this));

libs/png_support/png.js

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/png_support/zlib.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ var DecodeStream = (function() {
122122
})();
123123

124124
var FlateStream = (function() {
125+
if (typeof Uint32Array === 'undefined') {
126+
return undefined;
127+
}
125128
var codeLenCodeMap = new Uint32Array([
126129
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
127130
]);

libs/polyfill.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,4 @@
186186
};
187187
}
188188

189-
})(this);
189+
})(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this);

0 commit comments

Comments
 (0)