Jul 13, 2017 On my most recent assignment I was faced with the challenge of downloading a pdf file from an API and displaying it in the browser. Normally, the API would provide a json-object with a link to the pdf, which can then be used to open a new browser tab/window and the browser. Iframes are embedded inside web pages. And you could embed an iframe in a page that is inside another iframe on another web page. When you set the target attribute to parent the link will open in the web page that is holding the iframe. In most situations with iframes, this target will open links in the same way that the parent target. I want to open a PDF file in my browser using iframe or object tag or what evere can do so I have an PDF.aspx page: Response.Buffer = false; //transmitfile self buffers Response.C.
Active2 years, 6 months ago
I want to open the pdf file in an iframe. I am using following code:
It is opening fine in Firefox, but it is not opening in IE8.
Does anyone know how to make it work also for IE ?
Andrea Ligios
41.7k1717 gold badges8383 silver badges188188 bronze badges
user1753210user1753210
4 Answers
Using an
iframe to 'render' a PDF will not work on all browsers; it depends on how the browser handles PDF files. Some browsers (such as Firefox and Chrome) have a built-in PDF rendered which allows them to display the PDF inline where as some older browsers (perhaps older versions of IE attempt to download the file instead).
Instead, I recommend checking out PDFObject which is a Javascript library to embed PDFs in HTML files. It handles browser compatibility pretty well and will most likely work on IE8.
In your HTML, you could set up a
div to display the PDFs:
Then, you can have Javascript code to embed a PDF in that AamirAamir
div :
4,46922 gold badges2424 silver badges4444 bronze badges
This is the code to link an HTTP(S) accessible PDF from an
<iframe> : Arcgis 10.1 free download.
Fiddle: http://jsfiddle.net/cEuZ3/1545/
EDIT: and you can use Javascript, from the
<a> tag (onclick event) to set iFrame' SRC attribute at runtime..
EDIT 2: Appearently, it is a bug (but there are workarounds):
Community♦
Andrea LigiosAndrea Ligios
Open Pdf In Iframe Windows 10
41.7k1717 gold badges8383 silver badges188188 bronze badges
It also important to make sure that the web server sends the file with Content-Disposition = inline.this might not be the case if you are reading the file yourself and send it's content to the browser:
in php it will look like this..
RoeyRoey
Atif TariqAtif Tariq
protected by Community♦Oct 17 '16 at 12:11
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead? Not the answer you're looking for? Browse other questions tagged javascripthtmlpdfiframebrowser or ask your own question.
Active7 years, 2 months ago
I have a solution in place for my site that renders a requested PDF document in a full page using the code below. Now my client wants the document rendered within an iframe. I can't seem to get it to work readily, maybe I am missing something obvious. The first code will properly display the PDF in a new window.
Bixolon srp 275. The iframe code looks like this:
I know I am supposed to use the src attribute for the filename, but the problem seems to be that the iframe loads before the Page_Load event fires, so the PDF is not created. Is there something obvious I am missing?
RobRob
1,17655 gold badges2222 silver badges4545 bronze badges
4 Answers
Use an ASHX handler. The source code to your getmypdf.ashx.cs handler should look something like this:
getmypdf.ashx would contain something like this:
And your iframe would look like this:
GraymatterGraymatter
5,64422 gold badges2323 silver badges4444 bronze badges
I actually solved this! The solution was to generate another aspx page (showpdf.aspx) with the code that renders the PDF (the meat of it being the Response.. code), then call that code in the iframe. I pass the necessary variable from the source page. Thanks all!
Rob
Iframe For PdfRob
1,17655 gold badges2222 silver badges4545 bronze badges
You need to set the SLaksSLaks
src=' to a different URL that serves a PDF.
719k147147 gold badges16911691 silver badges18101810 bronze badges
Open Pdf In Iframe C#M. AbbasM. AbbasOpen Pdf Blob In Iframe
5,68833 gold badges2525 silver badges3939 bronze badges
Open Pdf File In IframeNot the answer you're looking for? Browse other questions tagged asp.netiframe or ask your own question.Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |