Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem streaming PDF on IPad #7089

Closed
mdstevens40 opened this issue Mar 17, 2016 · 2 comments
Closed

Problem streaming PDF on IPad #7089

mdstevens40 opened this issue Mar 17, 2016 · 2 comments

Comments

@mdstevens40
Copy link

Hello,

I'm have an application that is streaming a pdf from server to client and then displaying it using pdf.js. I finally got it working on desktop browsers but on the Ipad I get the error "file origin does not match viewwer's". Here is the javascript code which I am using to pull the pdf stream (FileStreamResult) from the server and then load it to pdf.js:

    var xhr = new XMLHttpRequest();
    xhr.open('GET', '/DataProfile/GetPdf?projectId=M2419', true);
    xhr.responseType = 'blob';

    xhr.onload = function (e) {
        if (this.status == 200) {
            var blob = new Blob([this.response], { type: 'application/pdf' });
            var url = URL.createObjectURL(blob);

            var viewerUrl = '/pdfviewer/viewer.html?file=' + encodeURIComponent(url);
            $("#frmMain").attr("src", viewerUrl);
        }
    };

    xhr.send();

I'm guessing that for some reason the createObjectURL method is generating a url with a different origin even though it works just fine on all desktop browsers. Any help would be appreciated.

@yurydelendik
Copy link
Contributor

The generic desktop viewer does not allow viewing cross origin URLs by default (see #6916). I wonder if iOS does not support URL constructor properly and PDF.js uses polyfill (at https://github.com/mozilla/pdf.js/blob/master/src/shared/util.js#L1681) which doesn't detect right origin for blob: URLs.

@yurydelendik
Copy link
Contributor

@mdstevens40 Can you provide iOS and Safari versions? Can you also verify if polyfill is used and also if createObjectURL() result contains origin information, e.g. "blob:http://mozilla.github.io/8af29137-6747-a642-89fc-e5d0db1dea3d"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants