Skip to content

Commit

Permalink
Ensuring the PNG support dont break the library initialization under …
Browse files Browse the repository at this point in the history
…older browsers
  • Loading branch information
diegocr committed Apr 29, 2014
1 parent 119a246 commit 4c69493
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 31 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jspdf",
"version": "1.0.118",
"version": "1.0.119",
"homepage": "https://github.com/mrrio/jspdf",
"description": "PDF Document creation from JavaScript",
"main": "dist/jspdf.min.js",
Expand Down
38 changes: 22 additions & 16 deletions dist/jspdf.debug.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @preserve
* jsPDF - PDF Document creation from JavaScript
* Version 1.0.118-git Built on 2014-04-28T19:38
* CommitID ce42cbafba
* Version 1.0.119-git Built on 2014-04-29T03:48
* CommitID 119a246e55
*
* Copyright (c) 2010-2014 James Hall, https://github.com/MrRio/jsPDF
* 2010 Aaron Spike, https://github.com/acspike
Expand Down Expand Up @@ -556,7 +556,7 @@ var jsPDF = (function(global) {
bch = ch >> 8; // divide by 256
if (bch >> 8) {
/* something left after dividing by 256 second time */
throw new Error("Character at position " + i.toString(10) + " of string '"
throw new Error("Character at position " + i + " of string '"
+ text + "' exceeds 16bits. Cannot be encoded into UCS-2 BE");
}
newtext.push(bch);
Expand Down Expand Up @@ -624,10 +624,10 @@ var jsPDF = (function(global) {
out(drawColor);
// resurrecting non-default line caps, joins
if (lineCapID !== 0) {
out(lineCapID.toString(10) + ' J');
out(lineCapID + ' J');
}
if (lineJoinID !== 0) {
out(lineJoinID.toString(10) + ' j');
out(lineJoinID + ' j');
}
events.publish('addPage', { pageNumber : page });
},
Expand Down Expand Up @@ -1576,7 +1576,7 @@ var jsPDF = (function(global) {
throw new Error("Line cap style of '" + style + "' is not recognized. See or extend .CapJoinStyles property for valid styles");
}
lineCapID = id;
out(id.toString(10) + ' J');
out(id + ' J');

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

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

if (typeof define === 'function') {
define(function() {
Expand All @@ -1703,7 +1703,7 @@ var jsPDF = (function(global) {
global.jsPDF = jsPDF;
}
return jsPDF;
}(self));
}(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this));
/**
* jsPDF addHTML PlugIn
* Copyright (c) 2014 Diego Casorran
Expand Down Expand Up @@ -7552,7 +7552,7 @@ var Deflater = (function(obj) {
*/


(function() {
(function(global) {
var PNG;

PNG = (function() {
Expand Down Expand Up @@ -7895,9 +7895,12 @@ var Deflater = (function(obj) {
return ret;
};

scratchCanvas = document.createElement('canvas');

scratchCtx = scratchCanvas.getContext('2d');
try {
scratchCanvas = global.document.createElement('canvas');
scratchCtx = scratchCanvas.getContext('2d');
} catch(e) {
return -1;
}

makeImage = function(imageData) {
var img;
Expand Down Expand Up @@ -7991,9 +7994,9 @@ var Deflater = (function(obj) {

})();

window.PNG = PNG;
global.PNG = PNG;

}).call(this);
})(typeof window !== "undefined" && window || this);
/*
* Extracted from pdf.js
* https://github.com/andreasgal/pdf.js
Expand Down Expand Up @@ -8118,6 +8121,9 @@ var DecodeStream = (function() {
})();

var FlateStream = (function() {
if (typeof Uint32Array === 'undefined') {
return undefined;
}
var codeLenCodeMap = new Uint32Array([
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
]);
Expand Down Expand Up @@ -8645,4 +8651,4 @@ var FlateStream = (function() {
};
}

})(this);
})(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this);
12 changes: 6 additions & 6 deletions dist/jspdf.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jspdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -1703,4 +1703,4 @@ var jsPDF = (function(global) {
global.jsPDF = jsPDF;
}
return jsPDF;
}(self));
}(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this));
15 changes: 9 additions & 6 deletions libs/png_support/png.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions libs/png_support/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ var DecodeStream = (function() {
})();

var FlateStream = (function() {
if (typeof Uint32Array === 'undefined') {
return undefined;
}
var codeLenCodeMap = new Uint32Array([
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
]);
Expand Down
2 changes: 1 addition & 1 deletion libs/polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,4 @@
};
}

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

0 comments on commit 4c69493

Please sign in to comment.