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?Answer1:
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: <a href="http://helpdesk.toitl.com/data/p/toitl.com/dv/dialog_with_pdf/" rel="nofollow">http://helpdesk.toitl.com/data/p/toitl.com/dv/dialog_with_pdf/</a>Answer2:
Some example code would be a big help.
I have done this using <a href="http://fancybox.net/" rel="nofollow">fancybox</a> which has proved very flexible.
This link may prove useful, too. <a href="https://stackoverflow.com/questions/5965990/populating-iframe-with-pdf-using-mvc-ie-issue/5969649#5969649" rel="nofollow">Populating Iframe with PDF - Using MVC [IE Issue]</a>Answer3:
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 <a href="http://docs.google.com/viewer?pli=1" rel="nofollow">http://docs.google.com/viewer?pli=1</a>