Question

In javascript, I have a variable which holds a pdf in base64 (the pdf is generated in flex and passed to js). I want to open it in the browser (ie I want the browser to display the open/save dialog box letting the user open or save the pdf).

I am using Data URI which works fine in some browsers, but is not supported in IE 6/7:

function getPdf(pdf) {
    window.open("data:application/pdf;base64," +pdf);
}

How can I get this PDF to open in IE6 and 7? I've read about MHTML as an alternative to data uri but I don't think it can do what I need, or can it? For now I just need to open pdfs but in the future I will probably need to add support for xls (MS Excel) files too. Currently I'm using Flash's Filereference.save to let the user save the pdf to the disk then he can open it, but the client is insisting on giving the user a choice to open it automatically rather than forcing him to save it first.

Was it helpful?

Solution

This is not possible in IE without sending it to a server and redirecting to a response page. If you're generating the PDF, you should just generate the appropriate HTML instead for IE.

OTHER TIPS

You may want to consider this alternative: have Flex send the PDF file to the server then have an iframe on the page automatically load that from the server. It's a round about way to get around the IE6 issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top