Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

I am having a method data.In that method i am using PdfLoadedDocument to read the pdf file and i am saving the files to the database and it is working properly.And then i have second method which have to display the content of the data that i have saved to the database.

I have written a code for that.I have written a query for retrieving the file from the database and then i have used the casting to convert the file in to bytes.
Then i have used memory stream and stream reader functions.But i want the content to be displayed as html format.how can i do that.

I am sending my code:
 public ActionResult Display()
        {

            try
            { var query = (from i in dbContext.Pdffiles
                             where i.Id == 1
                             select new { Name = i.File }).FirstOrDefault();


                byte[] buffer = (byte[])query.Name;
System.IO.MemoryStream ms = new System.IO.MemoryStream(buffer);
 PdfLoadedDocument ldDoc = new PdfLoadedDocument(ms);
MemoryStream m = new MemoryStream();
                ldDoc.Save(m);
                m.Seek(0, SeekOrigin.Begin);
                StreamReader sr = new StreamReader(m,?);//i think i need to write some additional functionality.please tell me any body having any idea 
                
                var s = sr.ReadToEnd();


                return Json(s, JsonRequestBehavior.AllowGet);



            }
            catch (NotSupportedException) { return Json(new { st = "exception" }); }


I have tried several methods in the ? but it is showing an error
Posted
Comments
Sandeep Mewara 11-Jun-12 8:55am    
What error?
wizardzz 11-Jun-12 12:23pm    
Are you trying to keep the same format as the 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