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
Turns out Chrome hates pop-ups. Unblock them for the win.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.