Make PDF display inline instead of separate PDF Reader window

I’ve got an ASP.NET ashx class that obtains data from a database, creates a PDF file utilizing iTextSharp, and streams the PDF to the web browser. The browser (IE and Firefox at least) is releasing Acrobat Reader as a separate window to open the file. I ‘d like for it to show inline within the internet browser. C# guide for setting pdf document showing in pdf reader http://www.iditect.com/tutorial/pdf-document/

Is that something I can entirely manage from the server side? I’m currently setting the Content-Type header to application/pdf, and I’ve attempted setting Content-Disposition and Content-Length. Nothing up until now has worked.

Is there another header I’m missing? Exists something in the PDF itself that tells the web browser the best ways to display it? Any other ideas?

Setting the content-disposition and content-type headers ought to do it, but you might also require to call Response.ClearHeaders() to clear other headers that have been set.

Attempt utilizing Fiddler to see the real headers and material from the reaction and compare them to those from a website that works like you want.

It’s working for me on IIS6, IE7, ASP.NET3.5. Have you attempted the very little case in a couple of web browsers? If so I’ll include my full source to the response.

it would have worked for you since of your customer side settings for Adobe or whatever PDF audience you are utilizing. If you have a various version, or have show in internet browser handicapped, it will not work.

OK, ends up it was a silly question, however I’m happy I asked it since I had actually never become aware of Fiddler (which led me to the answer, which is why I’m accepting tspauld’s response). The PDF is created by a web service that serves the file to a couple of different front-end websites. I was setting the content personality to inline in the service, but that didn’t matter, due to the fact that the web browser never got that header; it got the header from the front-end site (which was accessory). I altered it in the front-end site which fixed it.

So the answer is that you need to have Content-Type= application/pdf and Content-Disposition= inline; filename= Something.pdf, as others have actually said.

If you need to stream the response with an ashx rather of being able to return an aspx, I think you may be out of luck.

Otherwise, I think the settings to show in internet browser or not, is entirely client driven and out of your hands.

Anyway If my post does not appear clear to you, have an appearance at this sample The best ways to Show PDF files with ASP.NET

Inspect your installed variation of Adobe Acrobat. There is a setting in choices for “Web” and a checkbox that says “Display PDF in Browser”.

Thanks for the action. I’ve set my Acrobat Reader to display inline however that doesn’t seem to make a distinction. I have actually been to other PDF pages that display inline in my internet browser, but the one I’m serving doesn’t. I do not believe it’s strictly a customer issue.

If you have the spending plan, my business offers a set of products that consists of an AJAX based image viewer that will let you see the PDF pages in line without Acrobat at all. In its easiest type, it is simply a viewer, however you can layer in interactivity as you need.

Leave a Reply

Your email address will not be published. Required fields are marked *