SM Farhad Ali
SM Farhad Ali

Reputation: 1105

How to display a pdf file in web browser in asp.net mvc3

I have a pdf file named 102.pdf in my App_Data folder. I want to view this in my web browser like chrome.Here is my code. But I can not display it.

<iframe src="102.pdf" width="400" height="400"></iframe>

I am using VS11

Any help would be appreciated. Thanks in advance

Upvotes: 2

Views: 2882

Answers (2)

SM Farhad Ali
SM Farhad Ali

Reputation: 1105

`

<iframe src="@Url.Content("~/Content/pdfs/102.pdf")" width="1000" height="500"></iframe>

`

Its the solution for how to view a pdf file in asp.net MVC3 with razor engine.

Happy coding :)

Upvotes: 1

Akina91
Akina91

Reputation: 332

You can try something like this : http://forums.asp.net/t/1506499.aspx/1?Dynamic+pdf+generation+using+iTextSharp

And is it a requirement to render pdf? what you can do is produce a markup of the same pdf file in browser and make it available for download in pdf using lib like itext http://itextpdf.com/.

Upvotes: 1

Related Questions