base64 - Internet Explorer fails opening a pdf string file [SOLVED] -
i receive (from webservice don't manage) string content of pdf file.
on client's side, use function:
window.open('data:application/pdf;base64,'+encodeuri(thestringwiththepdfcontent));
as usual, works in every browser ie (11 in case), shows alert message: "do want allow website open app on computer?"
if no, empty white page opened.
if yes, tries open "data" file (as reads protocol in window.open, guess) and, doesn't find application that, sends me microsoft application store, suggests me download "imusic"
completely useless, of course.
i've changed internet options i've guessed help, none works.
any suggestion?
thanks in advance,
i found solution , want share has same problem. can see demo here : https://jsfiddle.net/quangminh_ln/hy36tnt6/
'use strict'; var data = "...your pdf base64 string..."; var filename = "your_file_name"; if (window.navigator && window.navigator.mssaveoropenblob) { // ie workaround var bytecharacters = atob(data); var bytenumbers = new array(bytecharacters.length); (var = 0; < bytecharacters.length; i++) { bytenumbers[i] = bytecharacters.charcodeat(i); } var bytearray = new uint8array(bytenumbers); var blob = new blob([bytearray], {type: 'application/pdf'}); window.navigator.mssaveoropenblob(blob, filename); } else { // easier if not ie window.open("data:application/pdf;base64, " + data, '', "height=600,width=800"); }
the link saw solution : https://viethoblog.wordpress.com/2016/08/30/loaddisplay-pdf-from-base64-string-bonus-ie-workaround/
Comments
Post a Comment