Trouble loading PDF on Chrome IOS Trouble loading PDF on Chrome IOS google-chrome google-chrome

Trouble loading PDF on Chrome IOS


Try to parse document to base64 and added to your document or iframe.

    function getAsyncBase64(fileName, callBack){        var xhr = new XMLHttpRequest();        xhr.open('GET', fileName, true);        xhr.responseType = 'arraybuffer';        xhr.onload = function (e) {        if (this.status == 200) {            var uInt8Array = new Uint8Array(this.response || this.responseText);            var i = uInt8Array.length;            var binaryString = new Array(i);            while (i--) {                binaryString[i] = String.fromCharCode(uInt8Array[i]);            }            var dataBinary = binaryString.join('');            var data64 = window.btoa(dataBinary);            callback(data64);                        }        xhr.send();    };    function callback(base64){        window.open(base64, "_blank");        //or        iframe.src = "data:application/pdf;base64,"+ base64;    };    getAsyncBase64(url,callback);


If it's a popup/download issue you might be able to show it using an iframe?

<iframe src="downloads/report.pdf"></iframe>


I also think that popup behavior is probably high on the list of suspects (specifically the window.close(); line seems pretty suspicious especially if the popup is blocked by the user).

However, since the ultimate goal is to download the file, you could try changing the response headers to

Content-Disposition: attachment; filename="pp66.26.pdf"Content-Length: 31706Content-Type: applicaton/octet-stream

or you could try forcing all pdfs in a particular folder to force a download via .htaccess file, then just linking to them via the location.href you are using:

<FilesMatch "\.pdf$">ForceType applicaton/octet-streamHeader set Content-Disposition attachment</FilesMatch>