|
|
@ -112,6 +112,35 @@ function stringToPDFString(str) { |
|
|
|
return str2; |
|
|
|
return str2; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// getPdf()
|
|
|
|
|
|
|
|
// Convenience function to perform binary Ajax GET
|
|
|
|
|
|
|
|
// Usage: getPdf('http://...', callback)
|
|
|
|
|
|
|
|
// getPdf({url:String [,progress:Function]}, callback)
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
function getPdf(arg, callback) { |
|
|
|
|
|
|
|
var params = arg; |
|
|
|
|
|
|
|
if (typeof arg === 'string') { |
|
|
|
|
|
|
|
params = {url: arg}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var xhr = new XMLHttpRequest(); |
|
|
|
|
|
|
|
xhr.open('GET', params.url); |
|
|
|
|
|
|
|
xhr.mozResponseType = xhr.responseType = 'arraybuffer'; |
|
|
|
|
|
|
|
xhr.expected = (document.URL.indexOf('file:') === 0) ? 0 : 200; |
|
|
|
|
|
|
|
xhr.onprogress = params.progress || undefined; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.onreadystatechange = function() { |
|
|
|
|
|
|
|
var data; |
|
|
|
|
|
|
|
if (xhr.readyState === 4 && xhr.status === xhr.expected) { |
|
|
|
|
|
|
|
data = (xhr.mozResponseArrayBuffer || xhr.mozResponse || |
|
|
|
|
|
|
|
xhr.responseArrayBuffer || xhr.response); |
|
|
|
|
|
|
|
callback(data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
xhr.send(null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var Stream = (function streamStream() { |
|
|
|
var Stream = (function streamStream() { |
|
|
|
function constructor(arrayBuffer, start, length, dict) { |
|
|
|
function constructor(arrayBuffer, start, length, dict) { |
|
|
|
this.bytes = new Uint8Array(arrayBuffer); |
|
|
|
this.bytes = new Uint8Array(arrayBuffer); |
|
|
|