67298

Attempting to view pdf file though iframe using jQuery modal popup

Question:

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>

Recommend

  • Uploaded file rename to untitled Google drive
  • How to apply tcpdf tamil font by using codeigniter
  • How to display pdf ( or any document) from server in a new browser window through ajax call
  • One Note Api rejects Bearer Token, Error 401
  • Page split is not working in jsPDF
  • downloading .zip file with maximum file size limit
  • Android: Adding Layouts Dynamically By Inflating XML
  • How to fix this error? emacs.d/starter-kit.el: `flet' is an obsolete macro (as of 24.3); use ei
  • Why are files are different when downloading from an ASP.NET (AJAX download with Blob)
  • scrapy - item loader - default processors
  • MSVC10 /MP builds not multicore across folders in a project
  • Bundled scripts not working MVC
  • TextBox controls are not Working with Export To PDF(iTextSharp)
  • MySQL Query Tuning - Why is using a value from a variable so much slower than using a literal?
  • Clojure embed var to String, a alternative way? Like sprintf way?
  • how to create a downloadable csv file in appengine
  • WCF hosting issues
  • css Star-rating html
  • Memory usage and time for execution for another process using C#?
  • Fast way to alphabetically sort the contents of a file in java
  • Trouble downloading file from browser on Android
  • SOAP with Attachment / MIME content
  • HttpRequestMessage Content Disposition null when unit testing
  • Is there an easy way to associate an event with a ListViewItem?
  • How to align an image side by side with a heading element?
  • dismiss Progress Dialog in another Activity … Android
  • For loop with if condition on multiple R functions
  • how to upload multiple files in c# windows application
  • How to install a .deb file on a jailbroken iphone programmatically?
  • Handling un-mapped Rest path
  • DotNetZip - Calculate final zip size before calling Save(stream)
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • Unanticipated behavior
  • Is there a mandatory requirement to switch app.yaml?
  • File upload with ng-file-upload throwing error
  • ExecuteAsync RestSharp to allow backgroundWorker CancellationPending c#
  • AngularJs get employee from factory
  • Load html files in TinyMce
  • Free memory of cv::Mat loaded using FileStorage API
  • reshape alternating columns in less time and using less memory