I am trying to display a pdf file though iframe using jQuery modal popup, however, it's asking the user to download the file when the page loads instead of the pdf file being embedded inside the iframe when the modal dialog opens up.
How can I get around this?
I'm using MVC to output the pdf file, and to open instead of downloading, I used this:
Response.AddHeader("Content-Disposition", "inline; filename=mypdf.pdf");
For the sake of viewing it inside a dialog I choose to use an iframe inside a div, wich became my dialog:
<div class="dialog" style="display:none; overflow:scroll;">
<iframe src="mypdf.pdf"></iframe>
</div>
...
$(".dialog").dialog();
Make sure that your dialog div has overflow set to something different than 'auto'. Otherwise it wont display on IE.
Take a look at this link, if you need an example: http://helpdesk.toitl.com/data/p/toitl.com/dv/dialog_with_pdf/
Some example code would be a big help.
I have done this using fancybox which has proved very flexible.
This link may prove useful, too. Populating Iframe with PDF - Using MVC [IE Issue]
Whats causing this is different settings within the browsers because some browsers are set to display the pdf and some are set to download it.
One option is to try and create a flash object that will display the PDF.
Another option is google pdf viewer http://docs.google.com/viewer?pli=1