Click here to Skip to main content
15,893,790 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need to display the pdf file content in the Div or panel using C# or asp.net.help me out
Posted

Embed an iframe inside a div pointing to Google Doc Viewer and specifying the PDF file you want to display. This is the code you should add:

HTML
<iframe src="http://docs.google.com/gview?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>


Then you just need to set up your own document file to the "url" query string param and that's it! You can display not just PDF but any other file supported by the viewer like doc, xls, etc.
 
Share this answer
 
Comments
arun _91 19-Dec-13 6:23am    
how to get pdf file from loacal directory
Marc Gabrie 19-Dec-13 11:39am    
Create a Generic Handler (ashx file) called DisplayPdf.ashx then pass a param to it identifying your file. the url param for the Google Doc Viewer should look like this:
url=http://yourwebsite/DisplayPdf.ashx?id=123

Then in the handler (under ProcessRequest) just read the PDF from your local disk by using the id param i.e. something like this:

//get the id from the URL param
string myId = context.Request["id"];

//validate id and if success....
context.Response.ContentType = "application/pdf";
context.Response.BinaryWrite(System.IO.File.ReadAllBytes("c:\temp\yourfile.pdf"));

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