1

I'm xhr-POSTing some data to a server, who returns a PDF, which I handle as a blob (using iron-ajax's handle-as="blob" attribute, for the sake of completeness).
Now I want to display this blob/PDF in a new browser window (Chrome/Windows only).

I have already tried URL.createObjectURL(blob) and (new FileReader()).readAsDataURL(blob) -- both fail silently:

Method 1)

function handlePdfResponse(blob) {
    const pdfUrl = URL.createObjectURL(blob);
    window.open(pdfUrl, '_blank');
}

Method 2)

function handlePdfResponse(blob) {
    const reader = new FileReader();
    reader.onloadend = function(e) {
        window.open(reader.result, '_blank');
    };
    reader.readAsDataURL(blob);
}

In both cases, logging the input blob yields:

Blob {size: 219478, type: "application/pdf"}

Using the latter method, I can log the reader.result (which is a valid data-uri), paste it into a new Chrome window and gaze upon my shiny PDF.

There doesn't seem to be a way to debug either of these methods.

Thoughts?
Obvious errors?
Anything else I can try?

EDIT: Dear future generations: I'm on Chrome version 55.0

1 Answer 1

0

Turns out Chrome hates pop-ups. Unblock them for the win.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.