Open Pdf.js With A Data URL In IE11
I'm trying to use pdf.js for showing a document in a data URL on IE10. That is, something like this. It works well with Firefox or Chrome, but in Internet Explorer 10 and 11, the i
Solution 1:
Ok, if someone runs to the same problem, I solved it by bypassing the lib's normal loading path, and as async5 advised, converting directly the data to a byte array.
That is, in viewer.js, add those lines under line 6856 :
if (file && file.lastIndexOf('data:', 0) === 0) {
// data: url-scheme. we will load those with direct conversion to byte array
function convertDataURIToBinary(dataURI) {
var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
var base64 = dataURI.substring(base64Index);
var raw = window.atob(base64);
var rawLength = raw.length;
var array = new Uint8Array(new ArrayBuffer(rawLength));
for(var i = 0; i < rawLength; i++) {
array[i] = raw.charCodeAt(i);
}
return array;
}
// PDFViewerApplication.setTitleUsingUrl(file);
PDFViewerApplication.open(convertDataURIToBinary(file), 0);
return;
}
(the base64 to byte array code is the one posted by Codetoffel here)
Post a Comment for "Open Pdf.js With A Data URL In IE11"