Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,

How to open a pdf file in the view page of MVC. That pdf file is added into my project .I want after click on button that pdf file should open in view page not in another window..

If anybody know please help...its urjent

thanks in advance

Regards,
Apali
Posted
Updated 22-Jul-13 20:20pm
v2

Hi, please see this link:

http://stackoverflow.com/questions/6439634/mvc-view-pdf-in-partial[^]

Hope it helps! :)
 
Share this answer
 
Comments
Apali 23-Jul-13 1:45am    
thanks for link but in that link asp codes are there and in case of MVC <iframe src='<% Html.RenderAction("GetPDF"); %>' width="90%" height="90%" > smeone wrote I have already used that code but still I am not getting...please help...
Harshad Kathiriya 23-Jul-13 2:22am    
Hey
try to do this
-- CSHtml page
<iframe src="@Url.Action("GetPDF")" width="90%" height="90%">
</iframe>

-- In Controller
public FileStreamResult GetPDF()
{
FileStream fs = new FileStream(Server.MapPath(@"~\HTP.pdf"), FileMode.Open, FileAccess.Read);
return File(fs, "application/pdf");
}

same link below ---
http://stackoverflow.com/questions/6439634/mvc-view-pdf-in-partial[^]

:)
Apali 23-Jul-13 2:59am    
After using this code I am getting error like unable to open pdf file..please help
Harshad Kathiriya 23-Jul-13 3:16am    
I think some permission issue is there. Assign the full permission to that files.
Apali 23-Jul-13 3:23am    
i am not connecting to database so no need to give any permission here..any other...

FileStream fs = new FileStream(Server.MapPath(@"\D:\test.pdf"), FileMode.Open, FileAccess.Read); is this correct fully??
PDF files can be used by dint of fix pdf error file

http://www.fixpdferror.fixdamagedpdf.com
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900